Skip to content

Commit acf0a0c

Browse files
committed
Use wrapping shift for unsigned types
1 parent 2b5970f commit acf0a0c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/num/saturating.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ macro_rules! sh_impl_unsigned {
141141

142142
#[inline]
143143
fn shl(self, other: $f) -> Saturating<$t> {
144-
Saturating(self.0.shl((other & self::shift_max::$t as $f) as u32))
144+
Saturating(self.0.wrapping_shl(other as u32))
145145
}
146146
}
147147
forward_ref_binop! { impl Shl, shl for Saturating<$t>, $f,
@@ -162,7 +162,7 @@ macro_rules! sh_impl_unsigned {
162162

163163
#[inline]
164164
fn shr(self, other: $f) -> Saturating<$t> {
165-
Saturating(self.0.shr((other & self::shift_max::$t as $f) as u32))
165+
Saturating(self.0.wrapping_shr(other as u32))
166166
}
167167
}
168168
forward_ref_binop! { impl Shr, shr for Saturating<$t>, $f,

0 commit comments

Comments
 (0)