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

ConstrainedInteger's From impl allows for creating a ConstrainedInteger which is outside of the allowed range #399

Open
repnop opened this issue Jan 3, 2025 · 2 comments

Comments

@repnop
Copy link
Contributor

repnop commented Jan 3, 2025

currently the blanket From<T: Into<Integer>> impl allows creating an instance of ConstrainedInteger<START, END> with a value that exists outside of the constrained value. this should probably be changed to be a TryFrom impl instead where the bounds can be verified and Err returned if the converted-from value is outside of the range, though this would be a breaking change.

example:

let bar = rasn::types::ConstrainedInteger::<5, 100>::from(0u32);
@XAMPPRocky
Copy link
Collaborator

Thank you for your issue! A breaking change for this would be fine.

@repnop
Copy link
Contributor Author

repnop commented Jan 8, 2025

I attempted to implement this earlier and seems like the change for some reason runs afoul of a overlapping impl from core, so I'll have to investigate what's going on with that some other time.

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

No branches or pull requests

2 participants