Struct measurements::volume::Volume
source · [−]pub struct Volume { /* private fields */ }
Expand description
The Volume
struct can be used to deal with volumes in a common way.
#Example
use measurements::Volume;
let gallon = Volume::from_gallons(1.0);
let pint = Volume::from_pints(1.0);
let beers = gallon / pint;
println!("A gallon of beer will pour {} pints!", beers);
Implementations
sourceimpl Volume
impl Volume
sourcepub fn from_liters(liters: f64) -> Self
pub fn from_liters(liters: f64) -> Self
Create a new Volume from a floating point value in Liters (l)
sourcepub fn from_litres(liters: f64) -> Self
pub fn from_litres(liters: f64) -> Self
Create a new Volume from a floating point value in Litres (l)
sourcepub fn from_cubic_centimeters(cubic_centimeters: f64) -> Self
pub fn from_cubic_centimeters(cubic_centimeters: f64) -> Self
Create a new Volume from a floating point value in Cubic Centimeters (cc or cm³)
sourcepub fn from_cubic_centimetres(cubic_centimeters: f64) -> Self
pub fn from_cubic_centimetres(cubic_centimeters: f64) -> Self
Create a new Volume from a floating point value in Cubic Centimetres (cc or cm³)
sourcepub fn from_milliliters(milliliters: f64) -> Self
pub fn from_milliliters(milliliters: f64) -> Self
Create a new Volume from a floating point value in Milliliters (ml)
sourcepub fn from_millilitres(milliliters: f64) -> Self
pub fn from_millilitres(milliliters: f64) -> Self
Create a new Volume from a floating point value in Millilitres (ml)
sourcepub fn from_cubic_meters(cubic_meters: f64) -> Self
pub fn from_cubic_meters(cubic_meters: f64) -> Self
Create a new Volume from a floating point value in Cubic Meters (m³)
sourcepub fn from_cubic_metres(cubic_meters: f64) -> Self
pub fn from_cubic_metres(cubic_meters: f64) -> Self
Create a new Volume from a floating point value in Cubic Metres (m³)
sourcepub fn from_drops(drops: f64) -> Self
pub fn from_drops(drops: f64) -> Self
Create a new Volume from a floating point value in Drops
sourcepub fn from_drams(drams: f64) -> Self
pub fn from_drams(drams: f64) -> Self
Create a new Volume from a floating point value in US Fluid Drams
sourcepub fn from_teaspoons(teaspoons: f64) -> Self
pub fn from_teaspoons(teaspoons: f64) -> Self
Create a new Volume from a floating point value in Teaspoons (tsp)
sourcepub fn from_tablespoons(tablespoons: f64) -> Self
pub fn from_tablespoons(tablespoons: f64) -> Self
Create a new Volume from a floating point value in Tablespoons (tbsp)
sourcepub fn from_fluid_ounces_uk(fluid_ounces_uk: f64) -> Self
pub fn from_fluid_ounces_uk(fluid_ounces_uk: f64) -> Self
Create a new Volume from a floating point value in UK Fluid Ounces (fl oz)
sourcepub fn from_fluid_ounces(fluid_ounces: f64) -> Self
pub fn from_fluid_ounces(fluid_ounces: f64) -> Self
Create a new Volume from a floating point value in US Fluid Ounces (fl oz)
sourcepub fn from_cubic_inches(cubic_inches: f64) -> Self
pub fn from_cubic_inches(cubic_inches: f64) -> Self
Create a new Volume from a floating point value in Cubic Inches (cu in or in³)
sourcepub fn from_pints(pints: f64) -> Self
pub fn from_pints(pints: f64) -> Self
Create a new Volume from a floating point value in US Pints
sourcepub fn from_pints_uk(pints_uk: f64) -> Self
pub fn from_pints_uk(pints_uk: f64) -> Self
Create a new Volume from a floating point value in UK Pints
sourcepub fn from_quarts(quarts: f64) -> Self
pub fn from_quarts(quarts: f64) -> Self
Create a new Volume from a floating point value in Quarts
sourcepub fn from_gallons(gallons: f64) -> Self
pub fn from_gallons(gallons: f64) -> Self
Create a new Volume from a floating point value in US Gallons (gal US)
sourcepub fn from_gallons_uk(gallons_uk: f64) -> Self
pub fn from_gallons_uk(gallons_uk: f64) -> Self
Create a new Volume from a floating point value in UK/Imperial Gallons (gal)
sourcepub fn from_cubic_feet(cubic_feet: f64) -> Self
pub fn from_cubic_feet(cubic_feet: f64) -> Self
Create a new Volume from a floating point value in Cubic Feet (ft³)
sourcepub fn from_cubic_yards(cubic_yards: f64) -> Self
pub fn from_cubic_yards(cubic_yards: f64) -> Self
Create a new Volume from a floating point value in Cubic Yards (yd³)
sourcepub fn as_cubic_centimeters(&self) -> f64
pub fn as_cubic_centimeters(&self) -> f64
Convert Volume to a floating point value in Cubic Centimeters (cc or cm³)
sourcepub fn as_cubic_centimetres(&self) -> f64
pub fn as_cubic_centimetres(&self) -> f64
Convert Volume to a floating point value in Cubic Centimetres (cc or cm³)
sourcepub fn as_milliliters(&self) -> f64
pub fn as_milliliters(&self) -> f64
Convert Volume to a floating point value in Milliliters (ml)
sourcepub fn as_millilitres(&self) -> f64
pub fn as_millilitres(&self) -> f64
Convert Volume to a floating point value in Millilitres (ml)
sourcepub fn as_cubic_meters(&self) -> f64
pub fn as_cubic_meters(&self) -> f64
Convert Volume to a floating point value in Cubic Meters (m³)
sourcepub fn as_cubic_metres(&self) -> f64
pub fn as_cubic_metres(&self) -> f64
Convert Volume to a floating point value in Cubic Metres (m³)
sourcepub fn as_teaspoons(&self) -> f64
pub fn as_teaspoons(&self) -> f64
Convert Volume to a floating point value in Teaspoons (tsp)
sourcepub fn as_tablespoons(&self) -> f64
pub fn as_tablespoons(&self) -> f64
Convert Volume to a floating point value in Tablespoons (tbsp)
sourcepub fn as_cubic_inches(&self) -> f64
pub fn as_cubic_inches(&self) -> f64
Convert Volume to a floating point value in Cubic Inches (cu in or in³)
sourcepub fn as_fluid_ounces_uk(&self) -> f64
pub fn as_fluid_ounces_uk(&self) -> f64
Convert Volume to a floating point value in UK Fluid Ounces (fl oz)
sourcepub fn as_fluid_ounces(&self) -> f64
pub fn as_fluid_ounces(&self) -> f64
Convert Volume to a floating point value in US Fluid Ounces (fl oz)
sourcepub fn as_pints_uk(&self) -> f64
pub fn as_pints_uk(&self) -> f64
Convert Volume to a floating point value in UK Pints
sourcepub fn as_gallons(&self) -> f64
pub fn as_gallons(&self) -> f64
Convert Volume to a floating point value in US Gallons (gal us)
sourcepub fn as_gallons_uk(&self) -> f64
pub fn as_gallons_uk(&self) -> f64
Convert Volume to a floating point value in UK/Imperial Gallons (gal)
sourcepub fn as_cubic_feet(&self) -> f64
pub fn as_cubic_feet(&self) -> f64
Convert Volume to a floating point value in Cubic Feet (ft³)
sourcepub fn as_cubic_yards(&self) -> f64
pub fn as_cubic_yards(&self) -> f64
Convert Volume to a floating point value in Cubic Yards (yd³)
Trait Implementations
sourceimpl Measurement for Volume
impl Measurement for Volume
sourcefn as_base_units(&self) -> f64
fn as_base_units(&self) -> f64
Get this quantity in the base units
sourcefn from_base_units(units: f64) -> Self
fn from_base_units(units: f64) -> Self
Create a new quantity from the base units
sourcefn get_base_units_name(&self) -> &'static str
fn get_base_units_name(&self) -> &'static str
Return the base unit for this type, as a string. For example “kilograms” Read more
sourcefn get_appropriate_units(&self) -> (&'static str, f64)
fn get_appropriate_units(&self) -> (&'static str, f64)
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
sourceimpl PartialOrd<Volume> for Volume
impl PartialOrd<Volume> for Volume
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Volume
impl Eq for Volume
Auto Trait Implementations
impl RefUnwindSafe for Volume
impl Send for Volume
impl Sync for Volume
impl Unpin for Volume
impl UnwindSafe for Volume
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more