Struct astronomical_quantities::Length
source · pub struct Length { /* private fields */ }Expand description
The quantity of distance between two points in spacetime.
Reference unit: Astronomical Unit (‘au’)
Predefined units:
| Symbol | Name | Definition | Equivalent in ‘au’ |
|---|---|---|---|
| km | Kilometer | 1000·m | 6.684587122268446e-9 |
| ls | Lightsecond | 299792458·m | 0.002003988804100004 |
| ly | Lightyear | 31557600·ls | 63241.07708426629 |
| pc | Parsec | 648000/π·au | 206264.80624709636 |
| kly | Kilolightyear | 1000·ly | 63241077.08426629 |
| kpc | Kiloparsec | 1000·pc | 206264806.24709636 |
| Mly | Megalightyear | 10⁶·ly | 63241077084.26629 |
| Mpc | Megaparsec | 10⁶·pc | 206264806247.09636 |
| Gly | Gigalightyear | 10⁹·ly | 63241077084266.29 |
| Gpc | Gigaparsec | 10⁹·pc | 206264806247096.36 |
Trait Implementations§
source§impl Div<Duration> for Lengthwhere
Self: HasRefUnit,
Duration: HasRefUnit,
impl Div<Duration> for Lengthwhere Self: HasRefUnit, Duration: HasRefUnit,
source§impl Div<Speed> for Lengthwhere
Self: HasRefUnit,
Speed: HasRefUnit,
impl Div<Speed> for Lengthwhere Self: HasRefUnit, Speed: HasRefUnit,
source§impl HasRefUnit for Length
impl HasRefUnit for Length
source§const REF_UNIT: LengthUnit = LengthUnit::AstronomicalUnit
const REF_UNIT: LengthUnit = LengthUnit::AstronomicalUnit
Unit used as reference for scaling the units of
Self::UnitType.source§fn unit_from_scale(amnt: f64) -> Option<Self::UnitType>
fn unit_from_scale(amnt: f64) -> Option<Self::UnitType>
Returns
Some(unit) where unit.scale() == amnt, or None if
there is no such unit.source§fn equiv_amount(&self, unit: Self::UnitType) -> f64
fn equiv_amount(&self, unit: Self::UnitType) -> f64
Returns
factor so that factor * unit == self.source§fn convert(&self, to_unit: Self::UnitType) -> Self
fn convert(&self, to_unit: Self::UnitType) -> Self
Returns
qty where qty == self and qty.unit() is to_unit.source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Returns true, if
self and other have equivalent amounts, otherwise
false.source§impl PartialEq<Length> for Length
impl PartialEq<Length> for Length
source§impl PartialOrd<Length> for Length
impl PartialOrd<Length> for Length
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl Quantity for Length
impl Quantity for Length
§type UnitType = LengthUnit
type UnitType = LengthUnit
Associated type of unit
source§fn new(amount: AmountT, unit: Self::UnitType) -> Self
fn new(amount: AmountT, unit: Self::UnitType) -> Self
Returns a new instance of the type implementing
Quantity.source§fn iter_units<'a>() -> Iter<'a, Self::UnitType>
fn iter_units<'a>() -> Iter<'a, Self::UnitType>
Returns an iterator over the variants of
Self::UnitType.source§fn unit_from_symbol(symbol: &str) -> Option<Self::UnitType>
fn unit_from_symbol(symbol: &str) -> Option<Self::UnitType>
Returns
Some(unit) where unit.symbol() == symbol, or None if
there is no such unit.source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Return
true if self and other have the same unit and their amounts
are equal, otherwise false.source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Returns the partial order of
selfs and others amounts, if both have
the same unit, otherwise None.impl Copy for Length
impl Eq for Length
Auto Trait Implementations§
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> 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
Mutably borrows from an owned value. Read more