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
I would like to request a way to convert a bigint into a smaller primitive, saturating at MAX_VALUE or MIN_VALUE if needed.
The text was updated successfully, but these errors were encountered:
This seems like an unusual thing to want -- can you describe the use case where a saturating conversion would be helpful?
You can do this manually, if a little cumbersome, something like:
let small_int = bigint.to_i32().unwrap_or_else(|| { if bigint.sign() == Sign::Plus { i32::MAX } else { i32::MIN } });
Sorry, something went wrong.
Sorry, I was mistaken when I created this issue. I'm looking for a masking conversion to u64 where you discard the high bits.
No branches or pull requests
I would like to request a way to convert a bigint into a smaller primitive, saturating at MAX_VALUE or MIN_VALUE if needed.
The text was updated successfully, but these errors were encountered: