#[non_exhaustive]pub enum UnitSi {
Show 25 variants
Quetta,
Ronna,
Yotta,
Zetta,
Exa,
Peta,
Tera,
Giga,
Mega,
Kilo,
Hecto,
Deca,
None,
Deci,
Centi,
Milli,
Micro,
Nano,
Pico,
Femto,
Atto,
Zepto,
Yocto,
Ronto,
Quecto,
}
unit
only.Expand description
SI (metric) unit prefixes.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Quetta
10^30
Ronna
10^27
Yotta
10^24
Zetta
10^21
Exa
10^18
Peta
10^15
Tera
10^12
Giga
10^9
Mega
10^6
Kilo
10^3
Hecto
10^2
Deca
10^1
None
10^0 (no prefix)
Deci
10^-1
Centi
10^-2
Milli
10^-3
Micro
10^-6
Nano
10^-9
Pico
10^-12
Femto
10^-15
Atto
10^-18
Zepto
10^-21
Yocto
10^-24
Ronto
10^-27
Quecto
10^-30
Implementations§
Source§impl UnitSi
impl UnitSi
Sourcepub const fn symbol(&self) -> &str ⓘ
pub const fn symbol(&self) -> &str ⓘ
Returns the symbol of the prefix.
§Example
assert_eq![UnitSi::Giga.symbol(), "G"];
assert_eq![UnitSi::Micro.symbol(), "µ"];
Sourcepub const fn symbol_ascii(&self) -> &str ⓘ
pub const fn symbol_ascii(&self) -> &str ⓘ
Returns the ASCII symbol of the prefix.
Sourcepub const fn factor(&self) -> f64 ⓘ
pub const fn factor(&self) -> f64 ⓘ
Returns the multiplication factor for the SI prefix as an f64
.
Sourcepub const fn factor_i64(&self) -> i64 ⓘ
pub const fn factor_i64(&self) -> i64 ⓘ
Returns the multiplication factor for the SI prefix as an i64
.
Negative values represent reciprocal factors, indicating that the unit corresponds to a fractional multiplier (e.g., -1000 represents a factor of 1/1000).
This method only supports the range from Exa
to Atto
,
returning 0 for >= Zetta
and for <= Zepto
.
Sourcepub const fn factor_i128(&self) -> i128 ⓘ
pub const fn factor_i128(&self) -> i128 ⓘ
Returns the multiplication factor for the SI prefix as an i128
.
Sourcepub fn convert(value: f64, from: Self, to: Self) -> f64 ⓘ
pub fn convert(value: f64, from: Self, to: Self) -> f64 ⓘ
Converts a value from one SI prefix to another, returning the converted value.
Sourcepub fn convert_i64(value: i64, from: Self, to: Self) -> (i64, i64) ⓘ
pub fn convert_i64(value: i64, from: Self, to: Self) -> (i64, i64) ⓘ
Converts a value from one SI prefix to another, returning the converted value and the remainder.
Sourcepub fn convert_i128(value: i128, from: Self, to: Self) -> (i128, i128) ⓘ
pub fn convert_i128(value: i128, from: Self, to: Self) -> (i128, i128) ⓘ
Converts a value from one SI prefix to another, returning the converted value and the remainder.
Sourcepub fn reduce(value: f64) -> (f64, Self) ⓘ
Available on crate features std
or _float_f64
only.
pub fn reduce(value: f64) -> (f64, Self) ⓘ
std
or _float_f64
only.Reduces the given value to the most appropriate SI prefix as an f64
,
returning a tuple of the reduced size and the prefix.
Sourcepub const fn reduce_i64(value: i64) -> (i64, Self, i64) ⓘ
pub const fn reduce_i64(value: i64) -> (i64, Self, i64) ⓘ
Reduces the given value to the most appropriate SI prefix as an i64
,
returning a tuple of the reduced size, the prefix, and the remainder.
Sourcepub const fn reduce_i128(value: i128) -> (i128, Self, i128) ⓘ
pub const fn reduce_i128(value: i128) -> (i128, Self, i128) ⓘ
Reduces the given value to the most appropriate SI prefix as an i128
,
returning a tuple of the reduced size, the prefix, and the remainder.
Sourcepub fn reduce_chain(value: f64, threshold: f64) -> Vec<(f64, Self)> ⓘ
Available on crate feature std
, or crate features alloc
and _float_f64
only.
pub fn reduce_chain(value: f64, threshold: f64) -> Vec<(f64, Self)> ⓘ
std
, or crate features alloc
and _float_f64
only.Reduces the given value to a chain of appropriate SI prefixes as an f64
,
stopping when the remainder is less than the given threshold.
Trait Implementations§
Source§impl Unit for UnitSi
impl Unit for UnitSi
Source§fn symbol_ascii(&self) -> &str ⓘ
fn symbol_ascii(&self) -> &str ⓘ
Source§fn factor_i64(&self) -> i64 ⓘ
fn factor_i64(&self) -> i64 ⓘ
Source§fn factor_i128(&self) -> i128 ⓘ
fn factor_i128(&self) -> i128 ⓘ
Source§fn asc_iter() -> impl Iterator<Item = Self>
fn asc_iter() -> impl Iterator<Item = Self>
Source§fn desc_iter() -> impl Iterator<Item = Self>
fn desc_iter() -> impl Iterator<Item = Self>
Source§fn convert(value: f64, from: Self, to: Self) -> f64 ⓘ
fn convert(value: f64, from: Self, to: Self) -> f64 ⓘ
Source§fn convert_i64(value: i64, from: Self, to: Self) -> (i64, i64) ⓘ
fn convert_i64(value: i64, from: Self, to: Self) -> (i64, i64) ⓘ
Source§fn convert_i128(value: i128, from: Self, to: Self) -> (i128, i128) ⓘ
fn convert_i128(value: i128, from: Self, to: Self) -> (i128, i128) ⓘ
Source§fn reduce(value: f64) -> (f64, Self) ⓘ
fn reduce(value: f64) -> (f64, Self) ⓘ
value
to the most appropriate prefix as a f64,
returning a tuple of the reduced size and the prefix. Read moreSource§fn reduce_i64(value: i64) -> (i64, Self, i64) ⓘ
fn reduce_i64(value: i64) -> (i64, Self, i64) ⓘ
Source§fn reduce_i128(value: i128) -> (i128, Self, i128) ⓘ
fn reduce_i128(value: i128) -> (i128, Self, i128) ⓘ
Source§fn reduce_chain(value: f64, threshold: f64) -> Vec<(f64, Self)> ⓘ
fn reduce_chain(value: f64, threshold: f64) -> Vec<(f64, Self)> ⓘ
impl Copy for UnitSi
impl Eq for UnitSi
impl StructuralPartialEq for UnitSi
Auto Trait Implementations§
impl Freeze for UnitSi
impl RefUnwindSafe for UnitSi
impl Send for UnitSi
impl Sync for UnitSi
impl Unpin for UnitSi
impl UnwindSafe for UnitSi
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize ⓘ
fn byte_align(&self) -> usize ⓘ
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of_val(&self) -> usize ⓘ
fn mem_align_of_val(&self) -> usize ⓘ
Source§fn mem_size_of_val(&self) -> usize ⓘ
fn mem_size_of_val(&self) -> usize ⓘ
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.