We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Would you be open to a PR that adds SaturatingInto / SaturatingFrom traits?
SaturatingInto
SaturatingFrom
Eg:
trait SaturatingInto<T> { fn saturating_into(self) -> T; } impl SaturatingFrom<usize> for u64 { fn saturating_from(self) -> T { self.try_into().unwrap_or_else(u64::MAX) } }
This would allow more straightforward conversions so that instead of using:
assert_eq!(u8::value_from(-1i16).unwrap_or_saturate(), 0u8);
One may write:
assert_eq!(-1i16.saturating_into(), 0u8);
I would be happy to contribute this PR.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Would you be open to a PR that adds
SaturatingInto
/SaturatingFrom
traits?Eg:
This would allow more straightforward conversions so that instead of using:
One may write:
I would be happy to contribute this PR.
The text was updated successfully, but these errors were encountered: