pub trait Number: Add<Output = Self> + AddAssign<Self> + Sum<Self> + Sub<Output = Self> + SubAssign<Self> + Mul<Output = Self> + MulAssign<Self> + Div<Output = Self> + DivAssign<Self> + Rem<Output = Self> + RemAssign<Self> + Copy + Clone + PartialEq + PartialOrd + Send + Sync + Debug + Display + Default {
Show 20 methods
// Required methods
fn zero() -> Self;
fn one() -> Self;
fn mul_add(self, a: Self, b: Self) -> Self;
fn mul_add_assign(&mut self, a: Self, b: Self);
fn from<T: Number>(n: T) -> Self;
fn as_f32(self) -> f32;
fn as_f64(self) -> f64;
fn as_u64(self) -> u64;
fn as_i64(self) -> i64;
fn abs(self) -> Self;
fn abs_diff(self, other: Self) -> Self;
fn powi(self, exp: i32) -> Self;
fn num_bytes() -> usize;
fn from_le_bytes(bytes: &[u8]) -> Self;
fn to_le_bytes(self) -> Vec<u8>;
fn from_be_bytes(bytes: &[u8]) -> Self;
fn to_be_bytes(self) -> Vec<u8>;
fn epsilon() -> Self;
fn next_random<R: Rng>(rng: &mut R) -> Self;
// Provided method
fn type_name<'a>() -> &'a str { ... }
}
Expand description
Collections of Number
s can be used to calculate distances.
Required Methods§
sourcefn mul_add_assign(&mut self, a: Self, b: Self)
fn mul_add_assign(&mut self, a: Self, b: Self)
Replaces self
with self + a * b
.
sourcefn from_le_bytes(bytes: &[u8]) -> Self
fn from_le_bytes(bytes: &[u8]) -> Self
Reads a Number
from little endian bytes.
sourcefn to_le_bytes(self) -> Vec<u8>
fn to_le_bytes(self) -> Vec<u8>
Converts a Number
to little endian bytes.
sourcefn from_be_bytes(bytes: &[u8]) -> Self
fn from_be_bytes(bytes: &[u8]) -> Self
Reads a Number
from big endian bytes.
sourcefn to_be_bytes(self) -> Vec<u8>
fn to_be_bytes(self) -> Vec<u8>
Converts a Number
to big endian bytes.
sourcefn epsilon() -> Self
fn epsilon() -> Self
Returns the epsilon value for the type.
For floating point types, this is the difference between 1.0 and the next largest representable number.
For integer types, this is 0.
sourcefn next_random<R: Rng>(rng: &mut R) -> Self
fn next_random<R: Rng>(rng: &mut R) -> Self
Returns a random Number
.
Provided Methods§
Object Safety§
This trait is not object safe.