Enum si_scale::prefix::Prefix [−][src]
#[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” prefix, 1e-24
“zepto” prefix, 1e-21
“atto” prefix, 1e-18
“femto” prefix, 1e-15
“pico” prefix, 1e-12
“nano” prefix, 1e-9
“micro” prefix, 1e-6
“milli” prefix, 1e-3
unit prefix (empty), 1
“kilo” prefix, 1e3
“mega” prefix, 1e6
“giga” prefix, 1e9
“tera” prefix, 1e12
“peta” prefix, 1e15
“exa” prefix, 1e18
“zetta” prefix, 1e21
“yotta” prefix, 1e24
Implementations
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
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.
Auto Trait Implementations
impl RefUnwindSafe for Prefix
impl UnwindSafe for Prefix
Blanket Implementations
Mutably borrows from an owned value. Read more