Volume

Enum Volume 

Source
#[non_exhaustive]
pub enum Volume {
Show 13 variants Bushel, Gallon, Quart, Pint, Cup, FluidOunce, Tablespoon, Teaspoon, Kiloliter, Liter, Centiliter, Milliliter, Microliter,
}
Expand description

A unit of volume.

Measurements of volume are of the same kind as measurements of length with power 3. Thus, any measurement created with a volume unit can be converted to a a length unit cubed, and vice versa.

The listed abbreviations are the abbreviations used to parse the unit with FromStr. The main abbreviation comes first, followed by any alternate abbreviations that can be used.

The conversions are listed in terms of the base unit. The base unit for Volume is Volume::Liter.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Bushel

A US bushel (2150.42 cubic inches).

  • Abbreviation: bu

  • 1 bu = 35.2390704 L

§

Gallon

A US gallon (231 cubic inches).

  • Abbreviation: gal

  • 1 gal = 3.785411784 L

§

Quart

A US quart (57.75 cubic inches).

  • Abbreviation: qt

  • 1 qt = 0.946352946 L

§

Pint

A US pint (28.875 cubic inches).

  • Abbreviation: pt

  • 1 pt = 0.473176473 L

§

Cup

A US cup (8 fluid ounces).

  • Abbreviation: c

  • 1 c = 0.2365882365 L

§

FluidOunce

A US fluid ounce (1.8046875 cubic inches).

  • Abbreviation: floz

  • 1 floz = 0.0295735295625 L

§

Tablespoon

A US tablespoon (0.90234375 cubic inches).

  • Abbreviation: tbsp

  • 1 tbsp = 0.01478676478125 L

§

Teaspoon

A US teaspoon (0.30078125 cubic inches).

  • Abbreviation: tsp

  • 1 tsp = 0.00492892159375 L

§

Kiloliter

  • Abbreviation: kL

  • 1 kL = 1000.0 L

§

Liter

  • Abbreviation: L

  • 1 L = 1.0 L

§

Centiliter

  • Abbreviation: cL

  • 1 cL = 0.01 L

§

Milliliter

  • Abbreviation: mL

  • 1 mL = 0.001 L

§

Microliter

  • Abbreviation: µL, uL

  • 1 µL = 1e-6 L

Implementations§

Source§

impl Volume

Source

pub fn pow(&self, power: i8) -> Unit

Creates a Unit with this quantity type and specified power.

Source

pub fn squared(&self) -> Unit

Creates a Unit with this quantity type and power 2.

Source

pub fn cubed(&self) -> Unit

Creates a Unit with this quantity type and power 3.

Trait Implementations§

Source§

impl Clone for Volume

Source§

fn clone(&self) -> Volume

Returns a duplicate 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 Convert for Volume

Source§

const BASE: Self = Volume::Liter

The base unit of this unit. Read more
Source§

fn conversion_factor(&self) -> f64

Returns the conversion factor from &self to Convert::BASE, i.e. the value to multiply a quantity in this unit by, in order to get a quantity in Convert::BASE. If the self unit is the same as this unit, then this function should return 1.0. Read more
Source§

fn conversion_factor_to(&self, target: impl Into<Unit>) -> Option<f64>

Defines the conversion factor from Convert::BASE, to a base unit that Convert::BASE is derived from. Returns None if there is no conversion factor, meaning the two units are unrelated. Read more
Source§

impl Debug for Volume

Source§

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

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

impl Display for Volume

Source§

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

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

impl From<Volume> for Base

Source§

fn from(u: Volume) -> Self

Converts to this type from the input type.
Source§

impl From<Volume> for CompoundUnit

Source§

fn from(u: Volume) -> Self

Converts to this type from the input type.
Source§

impl From<Volume> for Unit

Source§

fn from(u: Volume) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Volume

Source§

type Err = InvalidUnit

The associated error which can be returned from parsing.
Source§

fn from_str(value: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl PartialEq for Volume

Source§

fn eq(&self, other: &Volume) -> 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 TryFrom<&str> for Volume

Source§

type Error = InvalidUnit

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

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Volume

Source§

impl Eq for Volume

Source§

impl StructuralPartialEq for Volume

Auto Trait Implementations§

§

impl Freeze for Volume

§

impl RefUnwindSafe for Volume

§

impl Send for Volume

§

impl Sync for Volume

§

impl Unpin for Volume

§

impl UnwindSafe for Volume

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.