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 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§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Returns the partial order of
self
s amount and other
s eqivalent
amount in self
s unit.Source§impl PartialOrd for Length
impl PartialOrd for Length
Source§impl Quantity for Length
impl Quantity for Length
Source§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() -> impl Iterator<Item = Self::UnitType>
fn iter_units() -> impl Iterator<Item = 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
self
s and other
s amounts, if both
have the same unit, otherwise None
.impl Copy for Length
impl Eq 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> 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