Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate with error with module path fails #186

Closed
vic1707 opened this issue Sep 20, 2024 · 3 comments · Fixed by #187
Closed

validate with error with module path fails #186

vic1707 opened this issue Sep 20, 2024 · 3 comments · Fixed by #187

Comments

@vic1707
Copy link
Contributor

vic1707 commented Sep 20, 2024

I don't know if the issue name is right or understandable sorry.

I found out that

#[nutype(validate(with = fs::exists, error = io::Error))]
struct File(PathBuf);

causes an error at the io::.
I think the macro should support that.

Current workaround

use std::io::Error as IoError; 🤷

@greyblake
Copy link
Owner

Good catch! Thanks for reporting! I will fix that.

Though, I'd like to point, that the example above is not gonna work anyway because the function passed to with = should return Result<(), Error>.
In case of fs::exists it returns Result<bool, Error>.

@vic1707
Copy link
Contributor Author

vic1707 commented Sep 21, 2024

Yup I got that too, I made a separate function to check if it exists and is a file 🙃
When opening the issue I reverted to that state and forgot to check if it compiled since I was interested by the macro parsing 🤣
That's my bad

@greyblake
Copy link
Owner

Fixed in #187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants