-
Notifications
You must be signed in to change notification settings - Fork 57
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
Please remove assert from library code #16
Comments
The asserts removed in this commit all follow the pattern: assert_eq!(some_struct.member, DEFAULT_VAL); These asserts seem to only exist for preventing re-assignment of struct values if they have already been assigned. This doesn't match what the builder pattern usually does in rust. Rather than implementing an error for this case, and giving these methods the signature: fn setter(self, val) -> Resutl<Self, Error::ReAssignment> I removed the asserts to retain the standard builder pattern signature: fn setter(self, val) -> Self Signed-off-by: Erich Heine <[email protected]>
Rather than panicking the calling application when the message Kind has already been set, return Err(Error::InvalidNla). Note: This adds the error type: Error::InvalidNla Signed-off-by: Erich Heine <[email protected]>
The use of If there is a better way to achieve it is welcome. |
The asserts removed in this commit all follow the pattern: assert_eq!(some_struct.member, DEFAULT_VAL); These asserts seem to only exist for preventing re-assignment of struct values if they have already been assigned. This doesn't match what the builder pattern usually does in rust. Rather than implementing an error for this case, and giving these methods the signature: fn setter(self, val) -> Resutl<Self, Error::ReAssignment> I removed the asserts to retain the standard builder pattern signature: fn setter(self, val) -> Self Signed-off-by: Erich Heine <[email protected]>
Rather than panicking the calling application when the message Kind has already been set, return Err(Error::InvalidNla). Note: This adds the error type: Error::InvalidNla Signed-off-by: Erich Heine <[email protected]>
Since this is crate/library, panic is never acceptable, we should never expect our user to catch panic. The If you want to assert user's input, please do that in the program using rtnetlink, not within, we are not CLI. |
The
traffic_control
folder has many assert, please replace them withfn XXX() -> Result<(), Error::InvalidNla>
The text was updated successfully, but these errors were encountered: