Skip to content

Commit

Permalink
Use wrapping shift for unsigned types
Browse files Browse the repository at this point in the history
  • Loading branch information
kellerkindt committed Aug 28, 2021
1 parent 2b5970f commit acf0a0c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/num/saturating.rs
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit acf0a0c

Please sign in to comment.