用法
pub const fn checked_pow(self, other:u32) -> Option<NonZeroIsize>
将非零值提高到整数幂。检查溢出并在溢出时返回None
。因此,结果不能归零。
例子
#![feature(nonzero_ops)]
let three = NonZeroIsize::new(3)?;
let twenty_seven = NonZeroIsize::new(27)?;
let half_max = NonZeroIsize::new(isize::MAX / 2)?;
assert_eq!(Some(twenty_seven), three.checked_pow(3));
assert_eq!(None, half_max.checked_pow(3));
相关用法
- Rust core::num::NonZeroIsize.checked_mul用法及代码示例
- Rust core::num::NonZeroIsize.checked_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.overflowing_abs用法及代码示例
- Rust core::num::NonZeroIsize.abs用法及代码示例
- Rust core::num::NonZeroIsize.wrapping_abs用法及代码示例
- Rust core::num::NonZeroIsize.unchecked_mul用法及代码示例
- Rust core::num::NonZeroIsize.trailing_zeros用法及代码示例
- 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.checked_pow。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。