Use wrapping shift for unsigned types

This commit is contained in:
Michael Watzko 2021-08-28 13:28:35 +02:00
parent 2b5970f993
commit acf0a0c394

View file

@ -141,7 +141,7 @@ macro_rules! sh_impl_unsigned {
#[inline]
fn shl(self, other: $f) -> Saturating<$t> {
Saturating(self.0.shl((other & self::shift_max::$t as $f) as u32))
Saturating(self.0.wrapping_shl(other as u32))
}
}
forward_ref_binop! { impl Shl, shl for Saturating<$t>, $f,
@ -162,7 +162,7 @@ macro_rules! sh_impl_unsigned {
#[inline]
fn shr(self, other: $f) -> Saturating<$t> {
Saturating(self.0.shr((other & self::shift_max::$t as $f) as u32))
Saturating(self.0.wrapping_shr(other as u32))
}
}
forward_ref_binop! { impl Shr, shr for Saturating<$t>, $f,