3

NonZeroU32 in std::num - Rust

 2 years ago
source link: https://doc.rust-lang.org/stable/std/num/struct.NonZeroU32.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

impl NonZeroU32[src]

pub const fn leading_zeros(self) -> u321.53.0 (const: 1.53.0)[src][−]

Returns the number of leading zeros in the binary representation of self.

On many architectures, this function can perform better than leading_zeros() on the underlying integer type, as special handling of zero can be avoided.

Examples

Basic usage:

let n = std::num::NonZeroU32::new(u32::MAX).unwrap();

assert_eq!(n.leading_zeros(), 0);
Run

pub const fn trailing_zeros(self) -> u321.53.0 (const: 1.53.0)[src][−]

Returns the number of trailing zeros in the binary representation of self.

On many architectures, this function can perform better than trailing_zeros() on the underlying integer type, as special handling of zero can be avoided.

Examples

Basic usage:

let n = std::num::NonZeroU32::new(0b0101000).unwrap();

assert_eq!(n.trailing_zeros(), 3);
Run

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK