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


Rust NonZeroI8.wrapping_abs用法及代码示例


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

用法

pub const fn wrapping_abs(self) -> NonZeroI8

包装绝对值,请参见 i8::wrapping_abs

示例

#![feature(nonzero_ops)]

let pos = NonZeroI8::new(1)?;
let neg = NonZeroI8::new(-1)?;
let min = NonZeroI8::new(i8::MIN)?;
let max = NonZeroI8::new(i8::MAX)?;

assert_eq!(pos, pos.wrapping_abs());
assert_eq!(pos, neg.wrapping_abs());
assert_eq!(min, min.wrapping_abs());

相关用法


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