用法
pub const fn wrapping_abs(self) -> NonZeroIsize
包装绝对值,请参见 isize::wrapping_abs
。
示例
#![feature(nonzero_ops)]
let pos = NonZeroIsize::new(1)?;
let neg = NonZeroIsize::new(-1)?;
let min = NonZeroIsize::new(isize::MIN)?;
let max = NonZeroIsize::new(isize::MAX)?;
assert_eq!(pos, pos.wrapping_abs());
assert_eq!(pos, neg.wrapping_abs());
assert_eq!(min, min.wrapping_abs());
相关用法
- Rust core::num::NonZeroIsize.leading_zeros用法及代码示例
- Rust core::num::NonZeroIsize.saturating_pow用法及代码示例
- Rust core::num::NonZeroIsize.unsigned_abs用法及代码示例
- Rust core::num::NonZeroIsize.saturating_mul用法及代码示例
- Rust core::num::NonZeroIsize.checked_mul用法及代码示例
- Rust core::num::NonZeroIsize.checked_abs用法及代码示例
- Rust core::num::NonZeroIsize.overflowing_abs用法及代码示例
- Rust core::num::NonZeroIsize.abs用法及代码示例
- Rust core::num::NonZeroIsize.unchecked_mul用法及代码示例
- Rust core::num::NonZeroIsize.trailing_zeros用法及代码示例
- Rust core::num::NonZeroIsize.checked_pow用法及代码示例
- Rust core::num::NonZeroIsize.saturating_abs用法及代码示例
- Rust core::num::NonZeroIsize用法及代码示例
- Rust core::num::NonZeroI64.unchecked_mul用法及代码示例
- Rust core::num::NonZeroI32.checked_pow用法及代码示例
- Rust core::num::NonZeroI8.saturating_mul用法及代码示例
- Rust core::num::NonZeroI8.saturating_pow用法及代码示例
- Rust core::num::NonZeroI32.wrapping_abs用法及代码示例
- Rust core::num::NonZeroI16.checked_mul用法及代码示例
- Rust core::num::NonZeroI8.checked_abs用法及代码示例
注:本文由纯净天空筛选整理自rust-lang.org大神的英文原创作品 core::num::NonZeroIsize.wrapping_abs。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。