pub struct Mass(/* private fields */);Expand description
A mass quantity, stored canonically in kilograms (kg).
§Construction
use space_units::prelude::*;
let m = Mass::from_kg(1000.0);
let m2 = 5.0.kg(); // NumericExt shorthand§Supported units
| Constructor | Accessor | Unit |
|---|---|---|
from_kg | in_kg | kilogram (kg) |
from_g | in_g | gram (g) |
from_lb | in_lb | pound (lb) |
from_tonnes | in_tonnes | metric tonne (t) |
from_slug | in_slug | slug |
from_solar_masses | in_solar_masses | Solar mass (M_sun) |
from_earth_masses | in_earth_masses | Earth mass (M_earth) |
§Typed arithmetic
Implementations§
Source§impl Mass
impl Mass
Sourcepub const fn from_tonnes(val: f64) -> Self
pub const fn from_tonnes(val: f64) -> Self
Create from metric tonnes. 1 t = 1 000 kg.
Sourcepub const fn from_solar_masses(val: f64) -> Self
pub const fn from_solar_masses(val: f64) -> Self
Create from Solar masses. 1 M_sun = 1.989e30 kg.
Sourcepub const fn from_earth_masses(val: f64) -> Self
pub const fn from_earth_masses(val: f64) -> Self
Create from Earth masses. 1 M_earth = 5.972e24 kg.
Sourcepub const fn in_solar_masses(self) -> f64
pub const fn in_solar_masses(self) -> f64
Get value in Solar masses.
Sourcepub const fn in_earth_masses(self) -> f64
pub const fn in_earth_masses(self) -> f64
Get value in Earth masses.
Sourcepub fn display_as(self, unit: MassUnit) -> DisplayWithUnit
pub fn display_as(self, unit: MassUnit) -> DisplayWithUnit
Return a DisplayWithUnit for formatted printing in the given unit.
Trait Implementations§
Source§impl AddAssign for Mass
impl AddAssign for Mass
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl Div<Mass> for Energy
impl Div<Mass> for Energy
Source§type Output = SpecificEnergy
type Output = SpecificEnergy
The resulting type after applying the
/ operator.Source§impl Div<Mass> for Force
impl Div<Mass> for Force
Source§type Output = Acceleration
type Output = Acceleration
The resulting type after applying the
/ operator.Source§impl Div<Time> for Mass
impl Div<Time> for Mass
Source§type Output = MassFlowRate
type Output = MassFlowRate
The resulting type after applying the
/ operator.Source§impl DivAssign<f64> for Mass
impl DivAssign<f64> for Mass
Source§fn div_assign(&mut self, rhs: f64)
fn div_assign(&mut self, rhs: f64)
Performs the
/= operation. Read moreSource§impl Mul<Acceleration> for Mass
impl Mul<Acceleration> for Mass
Source§impl Mul<Mass> for Acceleration
impl Mul<Mass> for Acceleration
Source§impl MulAssign<f64> for Mass
impl MulAssign<f64> for Mass
Source§fn mul_assign(&mut self, rhs: f64)
fn mul_assign(&mut self, rhs: f64)
Performs the
*= operation. Read moreSource§impl PartialOrd for Mass
impl PartialOrd for Mass
Source§impl SubAssign for Mass
impl SubAssign for Mass
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl Copy for Mass
impl StructuralPartialEq for Mass
Auto Trait Implementations§
impl Freeze for Mass
impl RefUnwindSafe for Mass
impl Send for Mass
impl Sync for Mass
impl Unpin for Mass
impl UnsafeUnpin for Mass
impl UnwindSafe for Mass
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