用法
pub const fn wrapping_shl(self, rhs:u32) -> u8
Panic-free 按位 shift-left;产生 self << mask(rhs)
,其中 mask
删除 rhs
的任何 high-order 位,这将导致移位超过类型的位宽。
请注意,这与 rotate-left 不同;包装 shift-left 的 RHS 被限制在类型的范围内,而不是从 LHS 移出的位被返回到另一端。原始整数类型都实现了 rotate_left 函数,这可能是您想要的。
例子
基本用法:
assert_eq!(1u8.wrapping_shl(7), 128);
assert_eq!(1u8.wrapping_shl(128), 1);
相关用法
- Rust u8.wrapping_shr用法及代码示例
- Rust u8.wrapping_sub用法及代码示例
- Rust u8.wrapping_neg用法及代码示例
- Rust u8.wrapping_div用法及代码示例
- Rust u8.wrapping_rem用法及代码示例
- Rust u8.wrapping_next_power_of_two用法及代码示例
- Rust u8.wrapping_rem_euclid用法及代码示例
- Rust u8.wrapping_div_euclid用法及代码示例
- Rust u8.wrapping_add用法及代码示例
- Rust u8.wrapping_add_signed用法及代码示例
- Rust u8.wrapping_pow用法及代码示例
- Rust u8.wrapping_mul用法及代码示例
- Rust u8.widening_mul用法及代码示例
- Rust u8.rotate_left用法及代码示例
- Rust u8.is_power_of_two用法及代码示例
- Rust u8.saturating_sub用法及代码示例
- Rust u8.from_ne_bytes用法及代码示例
- Rust u8.saturating_add用法及代码示例
- Rust u8.overflowing_shr用法及代码示例
注:本文由纯净天空筛选整理自rust-lang.org大神的英文原创作品 u8.wrapping_shl。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。