Skip to main content

IsUnit

Trait IsUnit 

Source
pub trait IsUnit {
    // Required method
    fn is_unit(&self) -> bool;
}
Expand description

Determines whether a number is a unit of its ring, meaning that it has a multiplicative inverse in the same ring.

Which elements these are depends on the ring: the only unit of $\mathbb{N}$ is 1, the units of $\mathbb{Z}$ are $\pm 1$, the Gaussian integers have four, $\pm 1$ and $\pm i$, and in a field every nonzero element is a unit.

The implementations for the primitive integers follow suit, and the ones for the primitive floats count every finite nonzero value.

Required Methods§

Source

fn is_unit(&self) -> bool

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl IsUnit for f32

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is finite and nonzero, so that it has a multiplicative inverse. NaN and the infinities are not units.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for f64

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is finite and nonzero, so that it has a multiplicative inverse. NaN and the infinities are not units.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for i8

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1 or $-1$, the only integers with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for i16

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1 or $-1$, the only integers with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for i32

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1 or $-1$, the only integers with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for i64

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1 or $-1$, the only integers with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for i128

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1 or $-1$, the only integers with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for isize

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1 or $-1$, the only integers with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for u8

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1, the only unsigned integer with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for u16

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1, the only unsigned integer with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for u32

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1, the only unsigned integer with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for u64

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1, the only unsigned integer with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for u128

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1, the only unsigned integer with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl IsUnit for usize

Source§

fn is_unit(&self) -> bool

Determines whether a number is a unit: whether it is 1, the only unsigned integer with a multiplicative inverse.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Implementors§