pub struct Length(/* private fields */);Expand description
A length / distance quantity, stored canonically in meters (m).
§Construction
use space_units::prelude::*;
let a = Length::from_km(384_400.0);
let b = 384_400.0.km(); // NumericExt shorthand§Supported units
| Constructor | Accessor | Unit |
|---|---|---|
from_m | in_m | meter (m) |
from_km | in_km | kilometer (km) |
from_mm | in_mm | millimeter (mm) |
from_cm | in_cm | centimeter (cm) |
from_um | in_um | micrometer (um) |
from_nm | in_nm | nanometer (nm) |
from_au | in_au | astronomical unit (AU) |
from_pc | in_pc | parsec (pc) |
from_ly | in_ly | light-year (ly) |
from_ft | in_ft | foot (ft) |
from_nmi | in_nmi | nautical mile (nmi) |
from_mi | in_mi | statute mile (mi) |
from_earth_radii | in_earth_radii | Earth radius |
from_solar_radii | in_solar_radii | Solar radius |
§Typed arithmetic
Implementations§
Source§impl Length
impl Length
Sourcepub const fn from_au(val: f64) -> Self
pub const fn from_au(val: f64) -> Self
Create from astronomical units. 1 AU = 149 597 870 700 m.
Sourcepub const fn from_earth_radii(val: f64) -> Self
pub const fn from_earth_radii(val: f64) -> Self
Create from Earth radii. 1 R_earth = 6 371 000 m.
Sourcepub const fn from_solar_radii(val: f64) -> Self
pub const fn from_solar_radii(val: f64) -> Self
Create from Solar radii. 1 R_sun = 6.957e8 m.
Sourcepub const fn in_earth_radii(self) -> f64
pub const fn in_earth_radii(self) -> f64
Get value in Earth radii.
Sourcepub const fn in_solar_radii(self) -> f64
pub const fn in_solar_radii(self) -> f64
Get value in Solar radii.
Sourcepub fn in_unit(self, unit: LengthUnit) -> f64
pub fn in_unit(self, unit: LengthUnit) -> f64
Get value in the specified LengthUnit.
Sourcepub fn display_as(self, unit: LengthUnit) -> DisplayWithUnit
pub fn display_as(self, unit: LengthUnit) -> DisplayWithUnit
Return a DisplayWithUnit for formatted printing in the given unit.
Trait Implementations§
Source§impl AddAssign for Length
impl AddAssign for Length
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl Div<Length> for GravitationalParameter
impl Div<Length> for GravitationalParameter
Source§type Output = SpecificEnergy
type Output = SpecificEnergy
The resulting type after applying the
/ operator.Source§impl DivAssign<f64> for Length
impl DivAssign<f64> for Length
Source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
Performs the
/= operation. Read moreSource§impl Mul<Length> for Velocity
impl Mul<Length> for Velocity
Source§type Output = SpecificAngularMomentum
type Output = SpecificAngularMomentum
The resulting type after applying the
* operator.Source§impl Mul<Velocity> for Length
impl Mul<Velocity> for Length
Source§type Output = SpecificAngularMomentum
type Output = SpecificAngularMomentum
The resulting type after applying the
* operator.Source§impl MulAssign<f64> for Length
impl MulAssign<f64> for Length
Source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
Performs the
*= operation. Read moreSource§impl PartialOrd for Length
impl PartialOrd for Length
Source§impl SubAssign for Length
impl SubAssign for Length
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl Copy for Length
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 UnsafeUnpin 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