-
Notifications
You must be signed in to change notification settings - Fork 601
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
models/krate: Improve feature validation #7537
Conversation
Compared to the output of `assert!()` (`true != false`), these give a bit more context on the actual and expected values.
`valid` is a property name, which suggests that the fn returns a `bool`. If the fn returns a `Result` it's better to name the function like an action, e.g. `validate`.
The `models` module should ideally not know anything about the HTTP API layer and the `cargo_err()` fn.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thanks!
)] | ||
Char(char, String), | ||
#[error(transparent)] | ||
DependencyName(#[from] InvalidDependencyName), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm uncertain about placing it here, as it is also used in validate_dependency. It's not intended for validating the feature name. But I can help to improve it in my next PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InvalidDependencyName can also be used directly :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Got it. It's nice. Thanks!
As promised in #7500 (review), I have a few suggestions on how the feature validation code can be improved :)