Struct runtime_units::Mass

source ·
pub struct Mass {
    pub value: f64,
    pub unit: MassUnit,
}
Expand description

Mass (base unit kilogram, kg).

Fields§

§value: f64§unit: MassUnit

Implementations§

source§

impl Mass

source

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

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 to_quantity(&self) -> Quantity

Create a Quantity from this Mass.

Trait Implementations§

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 From<Mass> for MassQuantity

source§

fn from(quantity: 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 PartialEq for Mass

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Mass

source§

impl StructuralPartialEq for Mass

Auto Trait Implementations§

§

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> 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,

§

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>,

§

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>,

§

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.