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§
Source§impl 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)
Examples found in repository?
3fn main() {
4 for power in -12..12 {
5 let val: f64 = 123.456 * (10f64.powf(f64::from(power)));
6 println!("10^{}...", power);
7 println!("Temp of {0:.3} outside", Temperature::from_kelvin(val));
8 println!("Distance of {0:.3}", Length::from_meters(val));
9 println!("Pressure of {0:.3}", Pressure::from_millibars(val));
10 println!("Volume of {0:.3}", Volume::from_litres(val));
11 println!("Mass of {0:.3}", Mass::from_kilograms(val));
12 println!("Speed of {0:.3}", Speed::from_meters_per_second(val));
13 println!(
14 "Acceleration of {0:.3}",
15 Acceleration::from_meters_per_second_per_second(val)
16 );
17 println!("Energy of {0:.3}", Energy::from_joules(val));
18 println!("Power of {0:.3}", Power::from_watts(val));
19 println!("Force of {0:.3}", Force::from_newtons(val));
20 println!("Force of {0:.3}", Torque::from_newton_metres(val));
21 println!(
22 "Force of {0:.3}",
23 AngularVelocity::from_radians_per_second(val)
24 );
25 println!("Data size is {0:.3}", Data::from_octets(val));
26 }
27}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³)