#[repr(i32)]
pub enum Prefix {
Show 17 variants
Yocto,
Zepto,
Atto,
Femto,
Pico,
Nano,
Micro,
Milli,
Unit,
Kilo,
Mega,
Giga,
Tera,
Peta,
Exa,
Zetta,
Yotta,
}Expand description
Represents units’ SI prefixes.
Variants
Yocto
“yocto” prefix, 1e-24
Zepto
“zepto” prefix, 1e-21
Atto
“atto” prefix, 1e-18
Femto
“femto” prefix, 1e-15
Pico
“pico” prefix, 1e-12
Nano
“nano” prefix, 1e-9
Micro
“micro” prefix, 1e-6
Milli
“milli” prefix, 1e-3
Unit
unit prefix (empty), 1
Kilo
“kilo” prefix, 1e3
Mega
“mega” prefix, 1e6
Giga
“giga” prefix, 1e9
Tera
“tera” prefix, 1e12
Peta
“peta” prefix, 1e15
Exa
“exa” prefix, 1e18
Zetta
“zetta” prefix, 1e21
Yotta
“yotta” prefix, 1e24
Implementations
sourceimpl Prefix
impl Prefix
sourcepub fn exponent(&self) -> i32
pub fn exponent(&self) -> i32
Returns the exponent e for base.pow(e) to return the total
scaling factor. See Base::pow().
For instance,
-
if self is
-12(“pico”), thenexponent()returns-12so thatBase::B1000.pow(-12)returns the scaling factor1e-12. -
if self is
3(“kilo”), thenexponent()returns3so thatBase::B1024.pow(3)returns the scaling factor1024.
Trait Implementations
sourceimpl FromStr for Prefix
impl FromStr for Prefix
sourcefn from_str(s: &str) -> Result<Self>
fn from_str(s: &str) -> Result<Self>
Converts a &str into a Prefix if conversion is successful,
otherwise return an Err.
Example
use std::str::FromStr;
use si_scale::prelude::Prefix;
use si_scale::Result;
let actual= Prefix::from_str("y");
let expected = Ok(Prefix::Yocto);
assert_eq!(actual, expected);type Err = SIUnitsError
type Err = SIUnitsError
The associated error which can be returned from parsing.
impl Copy for Prefix
impl Eq for Prefix
impl StructuralEq for Prefix
impl StructuralPartialEq for Prefix
Auto Trait Implementations
impl RefUnwindSafe for Prefix
impl Send for Prefix
impl Sync for Prefix
impl Unpin for Prefix
impl UnwindSafe for Prefix
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more