Struct measurements::mass::Mass
[−]
[src]
pub struct Mass { /* fields omitted */ }
The Mass struct can be used to deal with mass in a common way. Metric, avoirdupois imperial and troy imperial units are supported.
#Example
use measurements::Mass; let metric_ton = Mass::from_metric_tons(1.0); let united_states_tons = metric_ton.as_short_tons(); let united_states_pounds = metric_ton.as_pounds(); println!( "One metric ton is {} U.S. tons - that's {} pounds!", united_states_tons, united_states_pounds);
Methods
impl Mass
[src]
pub fn from_kilograms(kilograms: f64) -> Self
[src]
Create a Mass from a floating point value in kilograms
pub fn from_micrograms(micrograms: f64) -> Self
[src]
Create a Mass from a floating point value in micrograms
pub fn from_milligrams(milligrams: f64) -> Self
[src]
Create a Mass from a floating point value in milligrams
pub fn from_carats(carats: f64) -> Self
[src]
Create a Mass from a floating point value in carats
pub fn from_grams(grams: f64) -> Self
[src]
Create a Mass from a floating point value in grams
pub fn from_metric_tons(metric_tons: f64) -> Self
[src]
Create a Mass from a floating point value in metric tonnes
pub fn from_tonnes(metric_tons: f64) -> Self
[src]
Create a Mass from a floating point value in metric tonnes
pub fn from_grains(grains: f64) -> Self
[src]
Create a Mass from a floating point value in grains
pub fn from_pennyweights(pennyweights: f64) -> Self
[src]
Create a Mass from a floating point value in pennyweights
pub fn from_ounces(ounces: f64) -> Self
[src]
Create a Mass from a floating point value in ounces
pub fn from_troy_ounces(troy_ounces: f64) -> Self
[src]
Create a Mass from a floating point value in troy_ounces
pub fn from_pounds(pounds: f64) -> Self
[src]
Create a Mass from a floating point value in Pounds (lbs)
pub fn from_troy_pounds(troy_pounds: f64) -> Self
[src]
Create a Mass from a floating point value in Troy Pounds
pub fn from_stones(stones: f64) -> Self
[src]
Create a Mass from a floating point value in Stone (st.)
pub fn from_short_tons(short_tons: f64) -> Self
[src]
Create a Mass from a floating point value in short (US) tons
pub fn from_long_tons(long_tons: f64) -> Self
[src]
Create a Mass from a floating point value in long (imperial) tons
pub fn as_micrograms(&self) -> f64
[src]
Convert this Mass to a floating point value in micrograms
pub fn as_milligrams(&self) -> f64
[src]
Convert this Mass to a floating point value in milligrams
pub fn as_carats(&self) -> f64
[src]
Convert this Mass to a floating point value in carats
pub fn as_grams(&self) -> f64
[src]
Convert this Mass to a floating point value in grams
pub fn as_kilograms(&self) -> f64
[src]
Convert this Mass to a floating point value in kilograms (kg)
pub fn as_metric_tons(&self) -> f64
[src]
Convert this Mass to a floating point value in metric Tonnes
pub fn as_tonnes(&self) -> f64
[src]
Convert this Mass to a floating point value in metric Tonnes
pub fn as_grains(&self) -> f64
[src]
Convert this Mass to a floating point value in Grains
pub fn as_pennyweights(&self) -> f64
[src]
Convert this Mass to a floating point value in Pennyweights
pub fn as_ounces(&self) -> f64
[src]
Convert this Mass to a floating point value in Ounces (oz)
pub fn as_pounds(&self) -> f64
[src]
Convert this Mass to a floating point value in Pounds (lbs)
pub fn as_troy_ounces(&self) -> f64
[src]
Convert this Mass to a floating point value in Troy Ounces
pub fn as_troy_pounds(&self) -> f64
[src]
Convert this Mass to a floating point value in Troy Pounds
pub fn as_stones(&self) -> f64
[src]
Convert this Mass to a floating point value in Stone (st.)
pub fn as_short_tons(&self) -> f64
[src]
Convert this Mass to a floating point value in short (US) Tons
pub fn as_long_tons(&self) -> f64
[src]
Convert this Mass to a floating point value in long (international) Tons
Trait Implementations
impl Copy for Mass
[src]
impl Clone for Mass
[src]
fn clone(&self) -> Mass
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Mass
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Measurement for Mass
[src]
fn as_base_units(&self) -> f64
[src]
Get this quantity in the base units
fn from_base_units(units: f64) -> Self
[src]
Create a new quantity from the base units
fn get_base_units_name(&self) -> &'static str
[src]
Return the base unit for this type, as a string. For example "kilograms" Read more
fn get_appropriate_units(&self) -> (&'static str, f64)
[src]
Returns a string containing the most appropriate units for this quantity, and a floating point value representing this quantity in those units. Useful when, for example, a length might be in millimeters if it is very small, or kilometers when it is very large. Read more
fn pick_appropriate_units(
&self,
list: &[(&'static str, f64)]
) -> (&'static str, f64)
[src]
&self,
list: &[(&'static str, f64)]
) -> (&'static str, f64)
Given a list of units and their scale relative to the base unit, select the most appropriate one. Read more
impl Display for Mass
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Add for Mass
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
Performs the +
operation.
impl Sub for Mass
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
Performs the -
operation.
impl Div<Mass> for Mass
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> f64
[src]
Performs the /
operation.
impl Div<f64> for Mass
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: f64) -> Self
[src]
Performs the /
operation.
impl Mul<f64> for Mass
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: f64) -> Self
[src]
Performs the *
operation.
impl Mul<Mass> for f64
[src]
type Output = Mass
The resulting type after applying the *
operator.
fn mul(self, rhs: Mass) -> Mass
[src]
Performs the *
operation.
impl Eq for Mass
[src]
impl PartialEq for Mass
[src]
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialOrd for Mass
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Mul<Mass> for Acceleration
[src]
type Output = Force
The resulting type after applying the *
operator.
fn mul(self, rhs: Mass) -> Self::Output
[src]
Performs the *
operation.
impl Mul<Acceleration> for Mass
[src]
type Output = Force
The resulting type after applying the *
operator.
fn mul(self, rhs: Acceleration) -> Self::Output
[src]
Performs the *
operation.