Struct measurements::length::Length
[−]
[src]
pub struct Length { /* fields omitted */ }
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);
Methods
impl Length
[src]
pub fn from_meters(meters: f64) -> Self
[src]
Create a new Length from a floating point value in meters
pub fn from_metres(metres: f64) -> Self
[src]
Create a new Length from a floating point value in metres.
pub fn from_nanometers(nanometers: f64) -> Self
[src]
Create a new Length from a floating point value in nanometers.
pub fn from_nanometres(nanometers: f64) -> Self
[src]
Create a new Length from a floating point value in nanometres.
pub fn from_micrometers(micrometers: f64) -> Self
[src]
Create a new Length from a floating point value in micrometers.
pub fn from_micrometres(micrometers: f64) -> Self
[src]
Create a new Length from a floating point value in micrometres.
pub fn from_millimeters(millimeters: f64) -> Self
[src]
Create a new Length from a floating point value in millimeters.
pub fn from_millimetres(millimeters: f64) -> Self
[src]
Create a new Length from a floating point value in millimetres.
pub fn from_centimeters(centimeters: f64) -> Self
[src]
Create a new Length from a floating point value in centimeters.
pub fn from_centimetres(centimeters: f64) -> Self
[src]
Create a new Length from a floating point value in centimetres.
pub fn from_decimeters(decimeters: f64) -> Self
[src]
Create a new Length from a floating point value in decimeters.
pub fn from_decimetres(decimeters: f64) -> Self
[src]
Create a new Length from a floating point value in decimetres.
pub fn from_hectometers(hectometers: f64) -> Self
[src]
Create a new Length from a floating point value in hectometers.
pub fn from_hectometres(hectometers: f64) -> Self
[src]
Create a new Length from a floating point value in hectometres.
pub fn from_kilometers(kilometers: f64) -> Self
[src]
Create a new Length from a floating point value in kilometers.
pub fn from_kilometres(kilometers: f64) -> Self
[src]
Create a new Length from a floating point value in kilometres.
pub fn from_inches(inches: f64) -> Self
[src]
Create a new Length from a floating point value in inches.
pub fn from_feet(feet: f64) -> Self
[src]
Create a new Length from a floating point value in feet.
pub fn from_yards(yards: f64) -> Self
[src]
Create a new Length from a floating point value in yards.
pub fn from_furlongs(furlongs: f64) -> Self
[src]
Create a new Length from a floating point value in furlongs.
pub fn from_miles(miles: f64) -> Self
[src]
Create a new Length from a floating point value in miles.
pub fn as_nanometers(&self) -> f64
[src]
Convert this Length to a floating point value in nanometers
pub fn as_nanometres(&self) -> f64
[src]
Convert this Length to a floating point value in nanometres
pub fn as_micrometers(&self) -> f64
[src]
Convert this Length to a floating point value in micrometers
pub fn as_micrometres(&self) -> f64
[src]
Convert this Length to a floating point value in micrometres
pub fn as_millimeters(&self) -> f64
[src]
Convert this Length to a floating point value in millimeters
pub fn as_millimetres(&self) -> f64
[src]
Convert this Length to a floating point value in millimetres
pub fn as_centimeters(&self) -> f64
[src]
Convert this Length to a floating point value in centimeters
pub fn as_centimetres(&self) -> f64
[src]
Convert this Length to a floating point value in centimetres
pub fn as_meters(&self) -> f64
[src]
Convert this Length to a floating point value in meters
pub fn as_metres(&self) -> f64
[src]
Convert this Length to a floating point value in metres
pub fn as_decimeters(&self) -> f64
[src]
Convert this Length to a floating point value in decimeters
pub fn as_decimetres(&self) -> f64
[src]
Convert this Length to a floating point value in decimetres
pub fn as_hectometers(&self) -> f64
[src]
Convert this Length to a floating point value in hectometers
pub fn as_hectometres(&self) -> f64
[src]
Convert this Length to a floating point value in hectometres
pub fn as_kilometers(&self) -> f64
[src]
Convert this Length to a floating point value in kilometers
pub fn as_kilometres(&self) -> f64
[src]
Convert this Length to a floating point value in kilometres
pub fn as_inches(&self) -> f64
[src]
Convert this Length to a floating point value in inches
pub fn as_feet(&self) -> f64
[src]
Convert this Length to a floating point value in feet
pub fn as_yards(&self) -> f64
[src]
Convert this Length to a floating point value in yards
pub fn as_furlongs(&self) -> f64
[src]
Convert this Length to a floating point value in furlongs
pub fn as_miles(&self) -> f64
[src]
Convert this Length to a floating point value in miles
Trait Implementations
impl Copy for Length
[src]
impl Clone for Length
[src]
fn clone(&self) -> Length
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Length
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Measurement for Length
[src]
fn as_base_units(&self) -> f64
[src]
Get this quantity in the base units
fn from_base_units(units: f64) -> Self
[src]
Create a new quantity from the base units
fn get_base_units_name(&self) -> &'static str
[src]
Return the base unit for this type, as a string. For example "kilograms" Read more
fn get_appropriate_units(&self) -> (&'static str, f64)
[src]
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
fn pick_appropriate_units(
&self,
list: &[(&'static str, f64)]
) -> (&'static str, f64)
[src]
&self,
list: &[(&'static str, f64)]
) -> (&'static str, f64)
Given a list of units and their scale relative to the base unit, select the most appropriate one. Read more
impl Display for Length
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Add for Length
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
Performs the +
operation.
impl Sub for Length
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
Performs the -
operation.
impl Div<Length> for Length
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> f64
[src]
Performs the /
operation.
impl Div<f64> for Length
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: f64) -> Self
[src]
Performs the /
operation.
impl Mul<f64> for Length
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: f64) -> Self
[src]
Performs the *
operation.
impl Mul<Length> for f64
[src]
type Output = Length
The resulting type after applying the *
operator.
fn mul(self, rhs: Length) -> Length
[src]
Performs the *
operation.
impl Eq for Length
[src]
impl PartialEq for Length
[src]
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialOrd for Length
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Mul<Length> for Length
[src]
type Output = Area
The resulting type after applying the *
operator.
fn mul(self, rhs: Length) -> Self::Output
[src]
Performs the *
operation.
impl Div<Length> for Area
[src]
type Output = Length
The resulting type after applying the /
operator.
fn div(self, rhs: Length) -> Self::Output
[src]
Performs the /
operation.
impl Div<Speed> for Length
[src]
type Output = Duration
The resulting type after applying the /
operator.
fn div(self, rhs: Speed) -> Self::Output
[src]
Performs the /
operation.
impl Div<Duration> for Length
[src]
type Output = Speed
The resulting type after applying the /
operator.
fn div(self, rhs: Duration) -> Self::Output
[src]
Performs the /
operation.
impl Mul<Length> for Area
[src]
type Output = Volume
The resulting type after applying the *
operator.
fn mul(self, rhs: Length) -> Self::Output
[src]
Performs the *
operation.
impl Mul<Area> for Length
[src]
type Output = Volume
The resulting type after applying the *
operator.
fn mul(self, rhs: Area) -> Self::Output
[src]
Performs the *
operation.
impl Div<Length> for Volume
[src]
type Output = Area
The resulting type after applying the /
operator.
fn div(self, rhs: Length) -> Self::Output
[src]
Performs the /
operation.
impl Mul<Force> for Length
[src]
type Output = TorqueEnergy
The resulting type after applying the *
operator.
fn mul(self, rhs: Force) -> Self::Output
[src]
Performs the *
operation.
impl Mul<Length> for Force
[src]
type Output = TorqueEnergy
The resulting type after applying the *
operator.
fn mul(self, rhs: Length) -> Self::Output
[src]
Performs the *
operation.
impl Div<Length> for TorqueEnergy
[src]
type Output = Force
The resulting type after applying the /
operator.
fn div(self, rhs: Length) -> Self::Output
[src]
Performs the /
operation.
impl Div<Length> for Torque
[src]
type Output = Force
The resulting type after applying the /
operator.
fn div(self, rhs: Length) -> Self::Output
[src]
Performs the /
operation.