-
Notifications
You must be signed in to change notification settings - Fork 133
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
Feature request: OverflowingShl #299
Comments
For most such things, it's just because nobody needed it yet. However, note that shifting is a bit weird compared to other checked/overflowing/wrapping ops, because See also rust-lang/libs-team#230 |
I am aware of And the thing is, this: let (res, ok) = 1usize.overflowing_shl(n);
res * (!ok as usize) is faster then this: 1usize.checked_shl(n).unwrap_or(0) https://rust.godbolt.org/z/3a6q5Wazf UPDATE: there were error in example |
I have need in
overflowing_shl
. Is there a reason, why there is no trait for it?P.S. Well, actually I need something like
saturating_shl
, but since there is no such thing in Rust,overflowing_shl
is the closest one.The text was updated successfully, but these errors were encountered: