Struct measurements::power::Power
[−]
[src]
pub struct Power { /* fields omitted */ }
The Power
struct can be used to deal with energies in a common way.
Common metric and imperial units are supported.
Example
use measurements::Power; let power = Power::from_horsepower(100.0); let k_w = power.as_kilowatts(); println!("A 100.0 hp car produces {} kW", k_w);
Methods
impl Power
[src]
pub fn from_watts(watts: f64) -> Power
[src]
Create a new Power from a floating point value in Watts
pub fn from_horsepower(horsepower: f64) -> Power
[src]
Create a new Power from a floating point value in horsepower (hp)
pub fn from_ps(ps: f64) -> Power
[src]
Create a new Power from a floating point value in metric horsepower (PS)
pub fn from_metric_horsepower(metric_horsepower: f64) -> Power
[src]
Create a new Power from a floating point value in metric horsepower (PS)
pub fn from_btu_per_minute(btu_per_minute: f64) -> Power
[src]
Create a new Power from a floating point value in BTU/mjn
pub fn from_kilowatts(kw: f64) -> Power
[src]
Create a new Power from a floating point value in Kilowatts (kW)
pub fn as_watts(&self) -> f64
[src]
Convert this Power into a floating point value in Watts
pub fn as_horsepower(&self) -> f64
[src]
Convert this Power into a floating point value in horsepower (hp)
pub fn as_ps(&self) -> f64
[src]
Convert this Power into a floating point value in metric horsepower (PS)
pub fn as_metric_horsepower(&self) -> f64
[src]
Convert this Power into a floating point value in metric horsepower (PS)
pub fn as_btu_per_minute(&self) -> f64
[src]
Convert this Power into a floating point value in BTU/min
pub fn as_kilowatts(&self) -> f64
[src]
Convert this Power into a floating point value in kilowatts (kW)
Trait Implementations
impl Copy for Power
[src]
impl Clone for Power
[src]
fn clone(&self) -> Power
[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 Power
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Measurement for Power
[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 Power
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Add for Power
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
Performs the +
operation.
impl Sub for Power
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
Performs the -
operation.
impl Div<Power> for Power
[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 Power
[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 Power
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: f64) -> Self
[src]
Performs the *
operation.
impl Mul<Power> for f64
[src]
type Output = Power
The resulting type after applying the *
operator.
fn mul(self, rhs: Power) -> Power
[src]
Performs the *
operation.
impl Eq for Power
[src]
impl PartialEq for Power
[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 Power
[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<Duration> for Power
[src]
type Output = Energy
The resulting type after applying the *
operator.
fn mul(self, rhs: Duration) -> Self::Output
[src]
Performs the *
operation.
impl Mul<Power> for Duration
[src]
type Output = Energy
The resulting type after applying the *
operator.
fn mul(self, rhs: Power) -> Self::Output
[src]
Performs the *
operation.
impl Div<Power> for Energy
[src]
type Output = Duration
The resulting type after applying the /
operator.
fn div(self, rhs: Power) -> Self::Output
[src]
Performs the /
operation.
impl Div<Speed> for Power
[src]
type Output = Force
The resulting type after applying the /
operator.
fn div(self, rhs: Speed) -> Self::Output
[src]
Performs the /
operation.
impl Div<Force> for Power
[src]
type Output = Speed
The resulting type after applying the /
operator.
fn div(self, rhs: Force) -> Self::Output
[src]
Performs the /
operation.
impl Div<Torque> for Power
[src]
type Output = AngularVelocity
The resulting type after applying the /
operator.
fn div(self, rhs: Torque) -> Self::Output
[src]
Performs the /
operation.
impl Div<AngularVelocity> for Power
[src]
type Output = Torque
The resulting type after applying the /
operator.
fn div(self, rhs: AngularVelocity) -> Self::Output
[src]
Performs the /
operation.
impl Div<Current> for Power
[src]
type Output = Voltage
The resulting type after applying the /
operator.
fn div(self, rhs: Current) -> Self::Output
[src]
Performs the /
operation.