Struct Mass

Source
pub struct Mass { /* private fields */ }
Expand description

Mass (base UnitDefinition kilogram, kg). Scalar storage of a quantity (f64 and MassUnit).

Implementations§

Source§

impl Mass

Source

pub fn new(value: f64, unit: MassUnit) -> Self

Create a new MassUnit.

Source

pub fn yottagram(value: f64) -> Self

Create a new Mass with units of MassUnit::yottagram.

Source

pub fn zettagram(value: f64) -> Self

Create a new Mass with units of MassUnit::zettagram.

Source

pub fn exagram(value: f64) -> Self

Create a new Mass with units of MassUnit::exagram.

Source

pub fn petagram(value: f64) -> Self

Create a new Mass with units of MassUnit::petagram.

Source

pub fn teragram(value: f64) -> Self

Create a new Mass with units of MassUnit::teragram.

Source

pub fn gigagram(value: f64) -> Self

Create a new Mass with units of MassUnit::gigagram.

Source

pub fn megagram(value: f64) -> Self

Create a new Mass with units of MassUnit::megagram.

Source

pub fn kilogram(value: f64) -> Self

Create a new Mass with units of MassUnit::kilogram.

Source

pub fn hectogram(value: f64) -> Self

Create a new Mass with units of MassUnit::hectogram.

Source

pub fn decagram(value: f64) -> Self

Create a new Mass with units of MassUnit::decagram.

Source

pub fn gram(value: f64) -> Self

Create a new Mass with units of MassUnit::gram.

Source

pub fn decigram(value: f64) -> Self

Create a new Mass with units of MassUnit::decigram.

Source

pub fn centigram(value: f64) -> Self

Create a new Mass with units of MassUnit::centigram.

Source

pub fn milligram(value: f64) -> Self

Create a new Mass with units of MassUnit::milligram.

Source

pub fn microgram(value: f64) -> Self

Create a new Mass with units of MassUnit::microgram.

Source

pub fn nanogram(value: f64) -> Self

Create a new Mass with units of MassUnit::nanogram.

Source

pub fn picogram(value: f64) -> Self

Create a new Mass with units of MassUnit::picogram.

Source

pub fn femtogram(value: f64) -> Self

Create a new Mass with units of MassUnit::femtogram.

Source

pub fn attogram(value: f64) -> Self

Create a new Mass with units of MassUnit::attogram.

Source

pub fn zeptogram(value: f64) -> Self

Create a new Mass with units of MassUnit::zeptogram.

Source

pub fn yoctogram(value: f64) -> Self

Create a new Mass with units of MassUnit::yoctogram.

Source

pub fn carat(value: f64) -> Self

Create a new Mass with units of MassUnit::carat.

Source

pub fn dalton(value: f64) -> Self

Create a new Mass with units of MassUnit::dalton.

Source

pub fn grain(value: f64) -> Self

Create a new Mass with units of MassUnit::grain.

Source

pub fn hundredweight_long(value: f64) -> Self

Create a new Mass with units of MassUnit::hundredweight_long.

Source

pub fn hundredweight_short(value: f64) -> Self

Create a new Mass with units of MassUnit::hundredweight_short.

Source

pub fn ounce(value: f64) -> Self

Create a new Mass with units of MassUnit::ounce.

Source

pub fn ounce_troy(value: f64) -> Self

Create a new Mass with units of MassUnit::ounce_troy.

Source

pub fn pennyweight(value: f64) -> Self

Create a new Mass with units of MassUnit::pennyweight.

Source

pub fn pound(value: f64) -> Self

Create a new Mass with units of MassUnit::pound.

Source

pub fn pound_troy(value: f64) -> Self

Create a new Mass with units of MassUnit::pound_troy.

Source

pub fn slug(value: f64) -> Self

Create a new Mass with units of MassUnit::slug.

Source

pub fn ton_assay(value: f64) -> Self

Create a new Mass with units of MassUnit::ton_assay.

Source

pub fn ton_long(value: f64) -> Self

Create a new Mass with units of MassUnit::ton_long.

Source

pub fn ton_short(value: f64) -> Self

Create a new Mass with units of MassUnit::ton_short.

Source

pub fn ton(value: f64) -> Self

Create a new Mass with units of MassUnit::ton.

Source

pub fn value(&self) -> f64

Retrieve the value associated with this Mass.

Source

pub fn value_mut(&mut self) -> &mut f64

Retrieve the mutable value associated with this Mass.

Source

pub fn definition(&self) -> UnitDefinition

Retrieve the UnitDefinition associated with this Mass.

Source

pub fn to_yottagram(&self) -> Self

Convert to MassUnit::yottagram.

Source

pub fn to_zettagram(&self) -> Self

Convert to MassUnit::zettagram.

Source

pub fn to_exagram(&self) -> Self

Convert to MassUnit::exagram.

Source

pub fn to_petagram(&self) -> Self

Convert to MassUnit::petagram.

Source

pub fn to_teragram(&self) -> Self

Convert to MassUnit::teragram.

Source

pub fn to_gigagram(&self) -> Self

Convert to MassUnit::gigagram.

Source

pub fn to_megagram(&self) -> Self

Convert to MassUnit::megagram.

Source

pub fn to_kilogram(&self) -> Self

Convert to MassUnit::kilogram.

Source

pub fn to_hectogram(&self) -> Self

Convert to MassUnit::hectogram.

Source

pub fn to_decagram(&self) -> Self

Convert to MassUnit::decagram.

Source

pub fn to_gram(&self) -> Self

Convert to MassUnit::gram.

Source

pub fn to_decigram(&self) -> Self

Convert to MassUnit::decigram.

Source

pub fn to_centigram(&self) -> Self

Convert to MassUnit::centigram.

Source

pub fn to_milligram(&self) -> Self

Convert to MassUnit::milligram.

Source

pub fn to_microgram(&self) -> Self

Convert to MassUnit::microgram.

Source

pub fn to_nanogram(&self) -> Self

Convert to MassUnit::nanogram.

Source

pub fn to_picogram(&self) -> Self

Convert to MassUnit::picogram.

Source

pub fn to_femtogram(&self) -> Self

Convert to MassUnit::femtogram.

Source

pub fn to_attogram(&self) -> Self

Convert to MassUnit::attogram.

Source

pub fn to_zeptogram(&self) -> Self

Convert to MassUnit::zeptogram.

Source

pub fn to_yoctogram(&self) -> Self

Convert to MassUnit::yoctogram.

Source

pub fn to_carat(&self) -> Self

Convert to MassUnit::carat.

Source

pub fn to_dalton(&self) -> Self

Convert to MassUnit::dalton.

Source

pub fn to_grain(&self) -> Self

Convert to MassUnit::grain.

Source

pub fn to_hundredweight_long(&self) -> Self

Source

pub fn to_hundredweight_short(&self) -> Self

Source

pub fn to_ounce(&self) -> Self

Convert to MassUnit::ounce.

Source

pub fn to_ounce_troy(&self) -> Self

Source

pub fn to_pennyweight(&self) -> Self

Source

pub fn to_pound(&self) -> Self

Convert to MassUnit::pound.

Source

pub fn to_pound_troy(&self) -> Self

Source

pub fn to_slug(&self) -> Self

Convert to MassUnit::slug.

Source

pub fn to_ton_assay(&self) -> Self

Convert to MassUnit::ton_assay.

Source

pub fn to_ton_long(&self) -> Self

Convert to MassUnit::ton_long.

Source

pub fn to_ton_short(&self) -> Self

Convert to MassUnit::ton_short.

Source

pub fn to_ton(&self) -> Self

Convert to MassUnit::ton.

Trait Implementations§

Source§

impl Add<Quantity> for Mass

Source§

type Output = Mass

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self

Performs the + operation. Read more
Source§

impl Add for Mass

Source§

type Output = Mass

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Mass) -> Self

Performs the + operation. Read more
Source§

impl AddAssign<Quantity> for Mass

Source§

fn add_assign(&mut self, rhs: Quantity)

Performs the += operation. Read more
Source§

impl AddAssign for Mass

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Mass

Source§

fn clone(&self) -> Mass

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Mass

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Mass

Source§

fn default() -> Mass

Returns the “default value” for a type. Read more
Source§

impl<T: IsScalarQuantity> Div<T> for Mass

Source§

type Output = Quantity

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Quantity

Performs the / operation. Read more
Source§

impl Div<f64> for Mass

Source§

type Output = Mass

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign<f64> for Mass

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl FixedQuantity<MassUnit> for Mass

Source§

fn unit(&self) -> MassUnit

Return unit associated with this quantity
Source§

fn convert(&self, unit: MassUnit) -> Self

Convert from this unit to another (creates a copy). No validation of base unit is made.
Source§

fn convert_mut(&mut self, unit: MassUnit)

Convert from this unit to another (modifies current quantity). No validation of base unit is made.
Source§

fn unit_mut(&mut self) -> &mut MassUnit

Return mutable unit associated with this quantity
Source§

fn try_convert(&self, unit: Units) -> Result<Self, RuntimeUnitError>
where Self: Sized,

Try to convert from this unit to another (creates a copy)
Source§

impl From<&Mass> for Units

Source§

fn from(value: &Mass) -> Self

Converts to this type from the input type.
Source§

impl From<Mass> for Quantity

Source§

fn from(quantity: Mass) -> Self

Converts to this type from the input type.
Source§

impl From<Mass> for UnitDefinition

Source§

fn from(value: Mass) -> Self

Converts to this type from the input type.
Source§

impl From<Mass> for Units

Source§

fn from(value: Mass) -> Self

Converts to this type from the input type.
Source§

impl From<Quantity> for Mass

Source§

fn from(quantity: Quantity) -> Mass

Converts to this type from the input type.
Source§

impl<T: IsScalarQuantity> Mul<T> for Mass

Source§

type Output = Quantity

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Quantity

Performs the * operation. Read more
Source§

impl Mul<f64> for Mass

Source§

type Output = Mass

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<f64> for Mass

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl PartialEq<Mass> for Quantity

Source§

fn eq(&self, other: &Mass) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Quantity> for Mass

Source§

fn eq(&self, other: &Quantity) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Mass

Source§

fn eq(&self, other: &Mass) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Mass

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<Quantity> for Mass

Source§

type Output = Mass

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self

Performs the - operation. Read more
Source§

impl Sub for Mass

Source§

type Output = Mass

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Mass) -> Self

Performs the - operation. Read more
Source§

impl SubAssign<Quantity> for Mass

Source§

fn sub_assign(&mut self, rhs: Quantity)

Performs the -= operation. Read more
Source§

impl SubAssign for Mass

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Copy 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 UnwindSafe for Mass

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.