Length

Enum Length 

Source
#[non_exhaustive]
pub enum Length {
Show 17 variants Parsec, LightYear, AstronomicalUnit, NauticalMile, Kilometer, Meter, Decimeter, Centimeter, Millimeter, Micrometer, Nanometer, Angstrom, Picometer, Mile, Yard, Foot, Inch,
}
Expand description

A unit of length.

The listed abbreviations are the abbreviations used to parse the unit with FromStr. The main abbreviation comes first, followed by any alternate abbreviations that can be used.

The conversions are listed in terms of the base unit. The base unit for Length is Length::Meter.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Parsec

  • Abbreviation: pc

  • 1 pc = 3.085677581e16 m

§

LightYear

  • Abbreviation: ly

  • 1 ly = 9.4607304725808e15 m

§

AstronomicalUnit

  • Abbreviation: au

  • 1 au = 1.495978707e11 m

§

NauticalMile

  • Abbreviation: nmi

  • 1 nmi = 1852.0 m

§

Kilometer

  • Abbreviation: km

  • 1 km = 1000.0 m

§

Meter

  • Abbreviation: m

  • 1 m = 1.0 m

§

Decimeter

  • Abbreviation: dm

  • 1 dm = 0.1 m

§

Centimeter

  • Abbreviation: cm

  • 1 cm = 0.01 m

§

Millimeter

  • Abbreviation: mm

  • 1 mm = 0.001 m

§

Micrometer

  • Abbreviation: µm, um

  • 1 µm = 1e-6 m

§

Nanometer

  • Abbreviation: nm

  • 1 nm = 1e-9 m

§

Angstrom

  • Abbreviation: Å, A

  • 1 Å = 1e-10 m

§

Picometer

  • Abbreviation: pm

  • 1 pm = 1e-12 m

§

Mile

  • Abbreviation: mi

  • 1 mi = 1609.344 m

§

Yard

  • Abbreviation: yd

  • 1 yd = 0.9144 m

§

Foot

  • Abbreviation: ft

  • 1 ft = 0.3048 m

§

Inch

  • Abbreviation: in

  • 1 in = 0.0254 m

Implementations§

Source§

impl Length

Source

pub fn pow(&self, power: i8) -> Unit

Creates a Unit with this quantity type and specified power.

Source

pub fn squared(&self) -> Unit

Creates a Unit with this quantity type and power 2.

Source

pub fn cubed(&self) -> Unit

Creates a Unit with this quantity type and power 3.

Trait Implementations§

Source§

impl Clone for Length

Source§

fn clone(&self) -> Length

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Convert for Length

Source§

const BASE: Self = Length::Meter

The base unit of this unit. Read more
Source§

fn conversion_factor(&self) -> f64

Returns the conversion factor from &self to Convert::BASE, i.e. the value to multiply a quantity in this unit by, in order to get a quantity in Convert::BASE. If the self unit is the same as this unit, then this function should return 1.0. Read more
Source§

fn conversion_factor_to(&self, _: impl Into<Unit>) -> Option<f64>

Defines the conversion factor from Convert::BASE, to a base unit that Convert::BASE is derived from. Returns None if there is no conversion factor, meaning the two units are unrelated. Read more
Source§

impl Debug for Length

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Length

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Length> for Base

Source§

fn from(u: Length) -> Self

Converts to this type from the input type.
Source§

impl From<Length> for CompoundUnit

Source§

fn from(u: Length) -> Self

Converts to this type from the input type.
Source§

impl From<Length> for Unit

Source§

fn from(u: Length) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Length

Source§

type Err = InvalidUnit

The associated error which can be returned from parsing.
Source§

fn from_str(value: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Length

Source§

fn eq(&self, other: &Length) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&str> for Length

Source§

type Error = InvalidUnit

The type returned in the event of a conversion error.
Source§

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Length

Source§

impl Eq for Length

Source§

impl StructuralPartialEq for Length

Auto Trait Implementations§

§

impl Freeze for Length

§

impl RefUnwindSafe for Length

§

impl Send for Length

§

impl Sync for Length

§

impl Unpin for Length

§

impl UnwindSafe for Length

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.