NumConst

Trait NumConst 

Source
pub trait NumConst: PartialEq<Self::Num> {
    type Num;
Show 18 associated constants and 12 methods const NUM_IS_BIG: bool; const NUM_IS_INT: bool; const NUM_IS_FLOAT: bool; const NUM_IS_FIXED: bool; const NUM_IS_SIGNED: bool; const NUM_IS_NICHE: bool; const NUM_ZERO: Option<Self::Num>; const NUM_ONE: Option<Self::Num>; const NUM_TWO: Option<Self::Num>; const NUM_THREE: Option<Self::Num>; const NUM_NEG_ONE: Option<Self::Num>; const NUM_MIN: Option<Self::Num>; const NUM_MAX: Option<Self::Num>; const NUM_MIN_POSITIVE: Option<Self::Num>; const NUM_MAX_NEGATIVE: Option<Self::Num>; const NUM_MIN_NORM: Option<Self::Num>; const NUM_MAX_NORM: Option<Self::Num>; const NUM_MAX_POWER_OF_TWO: Option<Self::Num>; // Provided methods fn is_num_zero(&self) -> bool { ... } fn is_num_one(&self) -> bool { ... } fn is_num_two(&self) -> bool { ... } fn is_num_three(&self) -> bool { ... } fn is_num_neg_one(&self) -> bool { ... } fn is_num_min(&self) -> bool { ... } fn is_num_max(&self) -> bool { ... } fn is_num_min_positive(&self) -> bool { ... } fn is_num_max_negative(&self) -> bool { ... } fn is_num_min_norm(&self) -> bool { ... } fn is_num_max_norm(&self) -> bool { ... } fn is_num_max_power_of_two(&self) -> bool { ... }
}
Expand description

๐Ÿ™ Fundamental numeric constants for both integer and floating-point types.

Required Associated Constantsยง

Source

const NUM_IS_BIG: bool

Whether the number can represent big quantities.

Source

const NUM_IS_INT: bool

Whether the number uses an integer representation.

Source

const NUM_IS_FLOAT: bool

Whether the number uses a floating-point representation.

Source

const NUM_IS_FIXED: bool

Whether the number uses a fixed-point representation.

Source

const NUM_IS_SIGNED: bool

Whether the number includes the sign.

Source

const NUM_IS_NICHE: bool

Whether the number has a memory niche optimization.

Source

const NUM_ZERO: Option<Self::Num>

The additive identity (0), if applicable.

Source

const NUM_ONE: Option<Self::Num>

The multiplicative identity (1).

Source

const NUM_TWO: Option<Self::Num>

The only even prime and the fundamental doubling factor (2).

Source

const NUM_THREE: Option<Self::Num>

The smallest odd prime and the first nontrivial divisor (3).

Source

const NUM_NEG_ONE: Option<Self::Num>

The additive inverse of ONE (-1), if applicable.

Source

const NUM_MIN: Option<Self::Num>

The smallest representable value.

Source

const NUM_MAX: Option<Self::Num>

The greatest representable value.

Source

const NUM_MIN_POSITIVE: Option<Self::Num>

The smallest representable positive value.

Source

const NUM_MAX_NEGATIVE: Option<Self::Num>

The greatest representable negative value, if applicable.

Source

const NUM_MIN_NORM: Option<Self::Num>

The smallest normalized value (e.g. 0.0 for float, MIN for integers).

Source

const NUM_MAX_NORM: Option<Self::Num>

The greatest normalized value (e.g. 1.0 for float, MAX for integers).

Source

const NUM_MAX_POWER_OF_TWO: Option<Self::Num>

The maximum representable power of two within the typeโ€™s range.

This is constructed using exact bit manipulation rather than arithmetic operations to ensure consistent results across all platforms.

Required Associated Typesยง

Source

type Num

The underlying numeric type implementing this trait.

Provided Methodsยง

Source

fn is_num_zero(&self) -> bool

Whether self is equal to NUM_ZERO.

Source

fn is_num_one(&self) -> bool

Whether self is equal to NUM_ONE.

Source

fn is_num_two(&self) -> bool

Whether self is equal to NUM_TWO.

Source

fn is_num_three(&self) -> bool

Whether self is equal to NUM_THREE.

Source

fn is_num_neg_one(&self) -> bool

Whether self is equal to NUM_NEG_ONE.

Source

fn is_num_min(&self) -> bool

Whether self is equal to NUM_MIN.

Source

fn is_num_max(&self) -> bool

Whether self is equal to NUM_MAX.

Source

fn is_num_min_positive(&self) -> bool

Whether self is equal to Some(NUM_MIN_POSITIVE).

Source

fn is_num_max_negative(&self) -> bool

Whether self is equal to NUM_MAX_NEGATIVE.

Source

fn is_num_min_norm(&self) -> bool

Whether self is equal to NUM_MIN_NORM.

Source

fn is_num_max_norm(&self) -> bool

Whether self is equal to NUM_MAX_NORM.

Source

fn is_num_max_power_of_two(&self) -> bool

Whether self is equal to NUM_MAX_POWER_OF_TWO.

Dyn Compatibilityยง

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Typesยง

Sourceยง

impl NumConst for f32

Sourceยง

impl NumConst for f64

Sourceยง

impl NumConst for i8

Sourceยง

impl NumConst for i16

Sourceยง

impl NumConst for i32

Sourceยง

impl NumConst for i64

Sourceยง

impl NumConst for i128

Sourceยง

impl NumConst for isize

Sourceยง

impl NumConst for u8

Sourceยง

impl NumConst for u16

Sourceยง

impl NumConst for u32

Sourceยง

impl NumConst for u64

Sourceยง

impl NumConst for u128

Sourceยง

impl NumConst for usize

Implementorsยง

Sourceยง

impl NumConst for NonZeroI8

Sourceยง

impl NumConst for NonZeroI16

Sourceยง

impl NumConst for NonZeroI32

Sourceยง

impl NumConst for NonZeroI64

Sourceยง

impl NumConst for NonZeroI128

Sourceยง

impl NumConst for NonZeroIsize

Sourceยง

impl NumConst for NonZeroU8

Sourceยง

impl NumConst for NonZeroU16

Sourceยง

impl NumConst for NonZeroU32

Sourceยง

impl NumConst for NonZeroU64

Sourceยง

impl NumConst for NonZeroU128

Sourceยง

impl NumConst for NonZeroUsize