Struct measurements::speed::Speed [−][src]
pub struct Speed { /* fields omitted */ }
The Speed
struct can be used to deal with speeds in a common way.
Common metric and imperial units are supported.
Example
use measurements::Speed; let light = Speed::from_meters_per_second(300_000_000.0); let mph = light.as_miles_per_hour(); println!("The speed of light is {} mph.", mph);
Methods
impl Speed
[src]
impl Speed
pub fn from_meters_per_second(meters_per_second: f64) -> Speed
[src]
pub fn from_meters_per_second(meters_per_second: f64) -> Speed
Create a new Speed from a floating point number of m/s
pub fn from_metres_per_second(metres_per_second: f64) -> Speed
[src]
pub fn from_metres_per_second(metres_per_second: f64) -> Speed
Create a new Speed from a floating point number of m/s
pub fn from_kilometers_per_hour(kilometers_per_hour: f64) -> Speed
[src]
pub fn from_kilometers_per_hour(kilometers_per_hour: f64) -> Speed
Create a new Speed from a floating point number of km/h (kph)
pub fn from_kilometres_per_hour(kilometres_per_hour: f64) -> Speed
[src]
pub fn from_kilometres_per_hour(kilometres_per_hour: f64) -> Speed
Create a new Speed from a floating point number of km/h (kph)
pub fn from_miles_per_hour(miles_per_hour: f64) -> Speed
[src]
pub fn from_miles_per_hour(miles_per_hour: f64) -> Speed
Create a new Speed from a floating point number of miles/hour (mph)
pub fn as_meters_per_second(&self) -> f64
[src]
pub fn as_meters_per_second(&self) -> f64
Convert this speed to a floating point number of m/s
pub fn as_metres_per_second(&self) -> f64
[src]
pub fn as_metres_per_second(&self) -> f64
Convert this speed to a floating point number of m/s
pub fn as_kilometers_per_hour(&self) -> f64
[src]
pub fn as_kilometers_per_hour(&self) -> f64
Convert this speed to a floating point number of km/hour (kph)
pub fn as_kilometres_per_hour(&self) -> f64
[src]
pub fn as_kilometres_per_hour(&self) -> f64
Convert this speed to a floating point number of km/hour (kph)
pub fn as_miles_per_hour(&self) -> f64
[src]
pub fn as_miles_per_hour(&self) -> f64
Convert this speed to a floating point number of miles/hour (mph)
Trait Implementations
impl Copy for Speed
[src]
impl Copy for Speed
impl Clone for Speed
[src]
impl Clone for Speed
fn clone(&self) -> Speed
[src]
fn clone(&self) -> Speed
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Speed
[src]
impl Debug for Speed
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Measurement for Speed
[src]
impl Measurement for Speed
fn as_base_units(&self) -> f64
[src]
fn as_base_units(&self) -> f64
Get this quantity in the base units
fn from_base_units(units: f64) -> Self
[src]
fn from_base_units(units: f64) -> Self
Create a new quantity from the base units
fn get_base_units_name(&self) -> &'static str
[src]
fn get_base_units_name(&self) -> &'static str
Return the base unit for this type, as a string. For example "kilograms" Read more
fn get_appropriate_units(&self) -> (&'static str, f64)
[src]
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
fn pick_appropriate_units(
&self,
list: &[(&'static str, f64)]
) -> (&'static str, f64)
[src]
fn pick_appropriate_units(
&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 Speed
[src]
impl Display for Speed
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Add for Speed
[src]
impl Add for Speed
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
fn add(self, rhs: Self) -> Self
Performs the +
operation.
impl Sub for Speed
[src]
impl Sub for Speed
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
fn sub(self, rhs: Self) -> Self
Performs the -
operation.
impl Div<Speed> for Speed
[src]
impl Div<Speed> for Speed
type Output = f64
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> f64
[src]
fn div(self, rhs: Self) -> f64
Performs the /
operation.
impl Div<f64> for Speed
[src]
impl Div<f64> for Speed
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: f64) -> Self
[src]
fn div(self, rhs: f64) -> Self
Performs the /
operation.
impl Mul<f64> for Speed
[src]
impl Mul<f64> for Speed
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: f64) -> Self
[src]
fn mul(self, rhs: f64) -> Self
Performs the *
operation.
impl Mul<Speed> for f64
[src]
impl Mul<Speed> for f64
type Output = Speed
The resulting type after applying the *
operator.
fn mul(self, rhs: Speed) -> Speed
[src]
fn mul(self, rhs: Speed) -> Speed
Performs the *
operation.
impl Eq for Speed
[src]
impl Eq for Speed
impl PartialEq for Speed
[src]
impl PartialEq for Speed
fn eq(&self, other: &Self) -> bool
[src]
fn eq(&self, other: &Self) -> bool
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]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl PartialOrd for Speed
[src]
impl PartialOrd for Speed
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
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]
fn lt(&self, other: &Rhs) -> bool
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]
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
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
fn gt(&self, other: &Rhs) -> bool
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]
fn ge(&self, other: &Rhs) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Mul<Duration> for Speed
[src]
impl Mul<Duration> for Speed
type Output = Length
The resulting type after applying the *
operator.
fn mul(self, rhs: Duration) -> Self::Output
[src]
fn mul(self, rhs: Duration) -> Self::Output
Performs the *
operation.
impl Mul<Speed> for Duration
[src]
impl Mul<Speed> for Duration
type Output = Length
The resulting type after applying the *
operator.
fn mul(self, rhs: Speed) -> Self::Output
[src]
fn mul(self, rhs: Speed) -> Self::Output
Performs the *
operation.
impl Div<Speed> for Length
[src]
impl Div<Speed> for Length
type Output = Duration
The resulting type after applying the /
operator.
fn div(self, rhs: Speed) -> Self::Output
[src]
fn div(self, rhs: Speed) -> Self::Output
Performs the /
operation.
impl Mul<Force> for Speed
[src]
impl Mul<Force> for Speed
type Output = Power
The resulting type after applying the *
operator.
fn mul(self, rhs: Force) -> Self::Output
[src]
fn mul(self, rhs: Force) -> Self::Output
Performs the *
operation.
impl Mul<Speed> for Force
[src]
impl Mul<Speed> for Force
type Output = Power
The resulting type after applying the *
operator.
fn mul(self, rhs: Speed) -> Self::Output
[src]
fn mul(self, rhs: Speed) -> Self::Output
Performs the *
operation.
impl Div<Speed> for Power
[src]
impl Div<Speed> for Power
type Output = Force
The resulting type after applying the /
operator.
fn div(self, rhs: Speed) -> Self::Output
[src]
fn div(self, rhs: Speed) -> Self::Output
Performs the /
operation.
impl Div<Acceleration> for Speed
[src]
impl Div<Acceleration> for Speed
type Output = Duration
The resulting type after applying the /
operator.
fn div(self, rhs: Acceleration) -> Self::Output
[src]
fn div(self, rhs: Acceleration) -> Self::Output
Performs the /
operation.
impl Div<Duration> for Speed
[src]
impl Div<Duration> for Speed