Struct measurements::length::Length
source · [−]pub struct Length { /* private fields */ }
Expand description
The Length struct can be used to deal with lengths in a common way. Common metric and imperial units are supported.
Example
use measurements::Length;
let football_field = Length::from_yards(100.0);
let meters = football_field.as_meters();
println!("There are {} meters in a football field.", meters);
Implementations
sourceimpl Length
impl Length
sourcepub fn from_meters(meters: f64) -> Self
pub fn from_meters(meters: f64) -> Self
Create a new Length from a floating point value in meters
sourcepub fn from_metres(metres: f64) -> Self
pub fn from_metres(metres: f64) -> Self
Create a new Length from a floating point value in metres.
sourcepub fn from_nanometers(nanometers: f64) -> Self
pub fn from_nanometers(nanometers: f64) -> Self
Create a new Length from a floating point value in nanometers.
sourcepub fn from_nanometres(nanometers: f64) -> Self
pub fn from_nanometres(nanometers: f64) -> Self
Create a new Length from a floating point value in nanometres.
sourcepub fn from_micrometers(micrometers: f64) -> Self
pub fn from_micrometers(micrometers: f64) -> Self
Create a new Length from a floating point value in micrometers.
sourcepub fn from_micrometres(micrometers: f64) -> Self
pub fn from_micrometres(micrometers: f64) -> Self
Create a new Length from a floating point value in micrometres.
sourcepub fn from_millimeters(millimeters: f64) -> Self
pub fn from_millimeters(millimeters: f64) -> Self
Create a new Length from a floating point value in millimeters.
sourcepub fn from_millimetres(millimeters: f64) -> Self
pub fn from_millimetres(millimeters: f64) -> Self
Create a new Length from a floating point value in millimetres.
sourcepub fn from_centimeters(centimeters: f64) -> Self
pub fn from_centimeters(centimeters: f64) -> Self
Create a new Length from a floating point value in centimeters.
sourcepub fn from_centimetres(centimeters: f64) -> Self
pub fn from_centimetres(centimeters: f64) -> Self
Create a new Length from a floating point value in centimetres.
sourcepub fn from_decimeters(decimeters: f64) -> Self
pub fn from_decimeters(decimeters: f64) -> Self
Create a new Length from a floating point value in decimeters.
sourcepub fn from_decimetres(decimeters: f64) -> Self
pub fn from_decimetres(decimeters: f64) -> Self
Create a new Length from a floating point value in decimetres.
sourcepub fn from_hectometers(hectometers: f64) -> Self
pub fn from_hectometers(hectometers: f64) -> Self
Create a new Length from a floating point value in hectometers.
sourcepub fn from_hectometres(hectometers: f64) -> Self
pub fn from_hectometres(hectometers: f64) -> Self
Create a new Length from a floating point value in hectometres.
sourcepub fn from_kilometers(kilometers: f64) -> Self
pub fn from_kilometers(kilometers: f64) -> Self
Create a new Length from a floating point value in kilometers.
sourcepub fn from_kilometres(kilometers: f64) -> Self
pub fn from_kilometres(kilometers: f64) -> Self
Create a new Length from a floating point value in kilometres.
sourcepub fn from_inches(inches: f64) -> Self
pub fn from_inches(inches: f64) -> Self
Create a new Length from a floating point value in inches.
sourcepub fn from_yards(yards: f64) -> Self
pub fn from_yards(yards: f64) -> Self
Create a new Length from a floating point value in yards.
sourcepub fn from_furlongs(furlongs: f64) -> Self
pub fn from_furlongs(furlongs: f64) -> Self
Create a new Length from a floating point value in furlongs.
sourcepub fn from_miles(miles: f64) -> Self
pub fn from_miles(miles: f64) -> Self
Create a new Length from a floating point value in miles.
sourcepub fn as_nanometers(&self) -> f64
pub fn as_nanometers(&self) -> f64
Convert this Length to a floating point value in nanometers
sourcepub fn as_nanometres(&self) -> f64
pub fn as_nanometres(&self) -> f64
Convert this Length to a floating point value in nanometres
sourcepub fn as_micrometers(&self) -> f64
pub fn as_micrometers(&self) -> f64
Convert this Length to a floating point value in micrometers
sourcepub fn as_micrometres(&self) -> f64
pub fn as_micrometres(&self) -> f64
Convert this Length to a floating point value in micrometres
sourcepub fn as_millimeters(&self) -> f64
pub fn as_millimeters(&self) -> f64
Convert this Length to a floating point value in millimeters
sourcepub fn as_millimetres(&self) -> f64
pub fn as_millimetres(&self) -> f64
Convert this Length to a floating point value in millimetres
sourcepub fn as_centimeters(&self) -> f64
pub fn as_centimeters(&self) -> f64
Convert this Length to a floating point value in centimeters
sourcepub fn as_centimetres(&self) -> f64
pub fn as_centimetres(&self) -> f64
Convert this Length to a floating point value in centimetres
sourcepub fn as_decimeters(&self) -> f64
pub fn as_decimeters(&self) -> f64
Convert this Length to a floating point value in decimeters
sourcepub fn as_decimetres(&self) -> f64
pub fn as_decimetres(&self) -> f64
Convert this Length to a floating point value in decimetres
sourcepub fn as_hectometers(&self) -> f64
pub fn as_hectometers(&self) -> f64
Convert this Length to a floating point value in hectometers
sourcepub fn as_hectometres(&self) -> f64
pub fn as_hectometres(&self) -> f64
Convert this Length to a floating point value in hectometres
sourcepub fn as_kilometers(&self) -> f64
pub fn as_kilometers(&self) -> f64
Convert this Length to a floating point value in kilometers
sourcepub fn as_kilometres(&self) -> f64
pub fn as_kilometres(&self) -> f64
Convert this Length to a floating point value in kilometres
sourcepub fn as_furlongs(&self) -> f64
pub fn as_furlongs(&self) -> f64
Convert this Length to a floating point value in furlongs
Trait Implementations
sourceimpl Div<Length> for TorqueEnergy
impl Div<Length> for TorqueEnergy
sourceimpl Measurement for Length
impl Measurement for Length
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<Length> for Length
impl PartialOrd<Length> for Length
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 Length
impl Eq for Length
Auto Trait Implementations
impl RefUnwindSafe for Length
impl Send for Length
impl Sync for Length
impl Unpin for Length
impl UnwindSafe for Length
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