pub trait ScientificNumber:
Num
+ Clone
+ Copy
+ PartialOrd
+ Debug
+ Zero
+ One
+ Add<Output = Self>
+ Sub<Output = Self>
+ Mul<Output = Self>
+ Div<Output = Self>
+ AddAssign
+ SubAssign
+ MulAssign
+ DivAssign
+ NumCast {
// Required methods
fn abs(self) -> Self;
fn sqrt(self) -> Self;
fn max(self, other: Self) -> Self;
fn min(self, other: Self) -> Self;
fn is_finite(self) -> bool;
fn to_f64(self) -> Option<f64>;
fn from_f64(value: f64) -> Option<Self>;
fn from_le_bytes(bytes: &[u8]) -> Self;
fn from_be_bytes(bytes: &[u8]) -> Self;
fn to_le_bytes(self) -> Vec<u8> ⓘ;
fn to_be_bytes(self) -> Vec<u8> ⓘ;
// Provided method
fn square(self) -> Self { ... }
}
Expand description
A trait for numeric types that can be used in scientific calculations
This trait combines common numeric traits required for scientific computing operations, providing a unified trait bound for generic code.
Required Methods§
Sourcefn from_le_bytes(bytes: &[u8]) -> Self
fn from_le_bytes(bytes: &[u8]) -> Self
Convert from little-endian bytes
Sourcefn from_be_bytes(bytes: &[u8]) -> Self
fn from_be_bytes(bytes: &[u8]) -> Self
Convert from big-endian bytes
Sourcefn to_le_bytes(self) -> Vec<u8> ⓘ
fn to_le_bytes(self) -> Vec<u8> ⓘ
Convert to little-endian bytes
Sourcefn to_be_bytes(self) -> Vec<u8> ⓘ
fn to_be_bytes(self) -> Vec<u8> ⓘ
Convert to big-endian bytes
Provided Methods§
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.