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ยง
Sourceconst NUM_IS_BIG: bool
const NUM_IS_BIG: bool
Whether the number can represent big quantities.
Sourceconst NUM_IS_INT: bool
const NUM_IS_INT: bool
Whether the number uses an integer representation.
Sourceconst NUM_IS_FLOAT: bool
const NUM_IS_FLOAT: bool
Whether the number uses a floating-point representation.
Sourceconst NUM_IS_FIXED: bool
const NUM_IS_FIXED: bool
Whether the number uses a fixed-point representation.
Sourceconst NUM_IS_SIGNED: bool
const NUM_IS_SIGNED: bool
Whether the number includes the sign.
Sourceconst NUM_IS_NICHE: bool
const NUM_IS_NICHE: bool
Whether the number has a memory niche optimization.
Sourceconst NUM_THREE: Option<Self::Num>
const NUM_THREE: Option<Self::Num>
The smallest odd prime and the first nontrivial divisor (3
).
Sourceconst NUM_NEG_ONE: Option<Self::Num>
const NUM_NEG_ONE: Option<Self::Num>
The additive inverse of ONE
(-1
), if applicable.
Sourceconst NUM_MIN_POSITIVE: Option<Self::Num>
const NUM_MIN_POSITIVE: Option<Self::Num>
The smallest representable positive value.
Sourceconst NUM_MAX_NEGATIVE: Option<Self::Num>
const NUM_MAX_NEGATIVE: Option<Self::Num>
The greatest representable negative value, if applicable.
Sourceconst NUM_MIN_NORM: Option<Self::Num>
const NUM_MIN_NORM: Option<Self::Num>
The smallest normalized value (e.g. 0.0 for float, MIN
for integers).
Sourceconst NUM_MAX_NORM: Option<Self::Num>
const NUM_MAX_NORM: Option<Self::Num>
The greatest normalized value (e.g. 1.0 for float, MAX
for integers).
Sourceconst NUM_MAX_POWER_OF_TWO: Option<Self::Num>
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ยง
Provided Methodsยง
Sourcefn is_num_zero(&self) -> bool
fn is_num_zero(&self) -> bool
Whether self
is equal to NUM_ZERO
.
Sourcefn is_num_one(&self) -> bool
fn is_num_one(&self) -> bool
Whether self
is equal to NUM_ONE
.
Sourcefn is_num_two(&self) -> bool
fn is_num_two(&self) -> bool
Whether self
is equal to NUM_TWO
.
Sourcefn is_num_three(&self) -> bool
fn is_num_three(&self) -> bool
Whether self
is equal to NUM_THREE
.
Sourcefn is_num_neg_one(&self) -> bool
fn is_num_neg_one(&self) -> bool
Whether self
is equal to NUM_NEG_ONE
.
Sourcefn is_num_min(&self) -> bool
fn is_num_min(&self) -> bool
Whether self
is equal to NUM_MIN
.
Sourcefn is_num_max(&self) -> bool
fn is_num_max(&self) -> bool
Whether self
is equal to NUM_MAX
.
Sourcefn is_num_min_positive(&self) -> bool
fn is_num_min_positive(&self) -> bool
Whether self
is equal to Some(
NUM_MIN_POSITIVE
)
.
Sourcefn is_num_max_negative(&self) -> bool
fn is_num_max_negative(&self) -> bool
Whether self
is equal to NUM_MAX_NEGATIVE
.
Sourcefn is_num_min_norm(&self) -> bool
fn is_num_min_norm(&self) -> bool
Whether self
is equal to NUM_MIN_NORM
.
Sourcefn is_num_max_norm(&self) -> bool
fn is_num_max_norm(&self) -> bool
Whether self
is equal to NUM_MAX_NORM
.
Sourcefn is_num_max_power_of_two(&self) -> bool
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.