Struct measurements::energy::Energy
[−]
[src]
pub struct Energy { /* fields omitted */ }
The Energy
struct can be used to deal with energies in a common way.
Common metric and imperial units are supported.
Example
use measurements::Energy; let energy = Energy::from_kcalories(2500.0); println!("Some say a health adult male should consume {} per day", energy);
Methods
impl Energy
[src]
pub fn from_joules(joules: f64) -> Energy
[src]
Create a new Energy from a floating point value in Joules (or watt-seconds)
pub fn from_kcalories(kcalories: f64) -> Energy
[src]
Create a new Energy from a floating point value in Kilocalories (often just called calories)
pub fn from_btu(btu: f64) -> Energy
[src]
Create a new Energy from a floating point value in British Thermal Units
pub fn from_e_v(e_v: f64) -> Energy
[src]
Create a new Energy from a floating point value in electron Volts (eV).
pub fn from_watt_hours(wh: f64) -> Energy
[src]
Create a new Energy from a floating point value in Watt-hours (Wh)
pub fn from_kilowatt_hours(kwh: f64) -> Energy
[src]
Create a new Energy from a floating point value in Kilowatt-Hours (kWh)
pub fn as_joules(&self) -> f64
[src]
Convert this Energy into a floating point value in Joules (or watt-seconds)
pub fn as_kcalories(&self) -> f64
[src]
Convert this Energy into a floating point value in Kilocalories (often just called calories)
pub fn as_btu(&self) -> f64
[src]
Convert this Energy into a floating point value in British Thermal Units
pub fn as_e_v(&self) -> f64
[src]
Convert this Energy into a floating point value in electron volts (eV)
pub fn as_watt_hours(&self) -> f64
[src]
Convert this Energy into a floating point value in Watt-hours (Wh)
pub fn as_kilowatt_hours(&self) -> f64
[src]
Convert this Energy into a floating point value in kilowatt-hours (kWh)
Trait Implementations
impl Copy for Energy
[src]
impl Clone for Energy
[src]
fn clone(&self) -> Energy
[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 Energy
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Measurement for Energy
[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 Energy
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Add for Energy
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
Performs the +
operation.
impl Sub for Energy
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
Performs the -
operation.
impl Div<Energy> for Energy
[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 Energy
[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 Energy
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: f64) -> Self
[src]
Performs the *
operation.
impl Mul<Energy> for f64
[src]
type Output = Energy
The resulting type after applying the *
operator.
fn mul(self, rhs: Energy) -> Energy
[src]
Performs the *
operation.
impl Eq for Energy
[src]
impl PartialEq for Energy
[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 Energy
[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 From<TorqueEnergy> for Energy
[src]
fn from(t: TorqueEnergy) -> Energy
[src]
Performs the conversion.
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<Duration> for Energy
[src]
type Output = Power
The resulting type after applying the /
operator.
fn div(self, rhs: Duration) -> Self::Output
[src]
Performs the /
operation.
impl Div<Length> for Energy
[src]
type Output = Force
The resulting type after applying the /
operator.
fn div(self, rhs: Length) -> Self::Output
[src]
Performs the /
operation.