当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Rust NonZeroU16.saturating_pow用法及代码示例


本文简要介绍rust语言中 core::num::NonZeroU16.saturating_pow 的用法。

用法

pub const fn saturating_pow(self, other: u32) -> NonZeroU16

将非零值提高到整数幂。溢出时返回 u16::MAX

例子

#![feature(nonzero_ops)]

let three = NonZeroU16::new(3)?;
let twenty_seven = NonZeroU16::new(27)?;
let max = NonZeroU16::new(u16::MAX)?;

assert_eq!(twenty_seven, three.saturating_pow(3));
assert_eq!(max, max.saturating_pow(3));

相关用法


注:本文由纯净天空筛选整理自rust-lang.org大神的英文原创作品 core::num::NonZeroU16.saturating_pow。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。