Struct measurements::energy::Energy
source · [−]pub struct Energy { /* private fields */ }
Expand description
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);
Implementations
sourceimpl Energy
impl Energy
sourcepub fn from_joules(joules: f64) -> Energy
pub fn from_joules(joules: f64) -> Energy
Create a new Energy from a floating point value in Joules (or watt-seconds)
sourcepub fn from_kcalories(kcalories: f64) -> Energy
pub fn from_kcalories(kcalories: f64) -> Energy
Create a new Energy from a floating point value in Kilocalories (often just called calories)
sourcepub fn from_btu(btu: f64) -> Energy
pub fn from_btu(btu: f64) -> Energy
Create a new Energy from a floating point value in British Thermal Units
sourcepub fn from_e_v(e_v: f64) -> Energy
pub fn from_e_v(e_v: f64) -> Energy
Create a new Energy from a floating point value in electron Volts (eV).
sourcepub fn from_watt_hours(wh: f64) -> Energy
pub fn from_watt_hours(wh: f64) -> Energy
Create a new Energy from a floating point value in Watt-hours (Wh)
sourcepub fn from_kilowatt_hours(kwh: f64) -> Energy
pub fn from_kilowatt_hours(kwh: f64) -> Energy
Create a new Energy from a floating point value in Kilowatt-Hours (kWh)
sourcepub fn as_joules(&self) -> f64
pub fn as_joules(&self) -> f64
Convert this Energy into a floating point value in Joules (or watt-seconds)
sourcepub fn as_kcalories(&self) -> f64
pub fn as_kcalories(&self) -> f64
Convert this Energy into a floating point value in Kilocalories (often just called calories)
sourcepub fn as_btu(&self) -> f64
pub fn as_btu(&self) -> f64
Convert this Energy into a floating point value in British Thermal Units
sourcepub fn as_e_v(&self) -> f64
pub fn as_e_v(&self) -> f64
Convert this Energy into a floating point value in electron volts (eV)
sourcepub fn as_watt_hours(&self) -> f64
pub fn as_watt_hours(&self) -> f64
Convert this Energy into a floating point value in Watt-hours (Wh)
sourcepub fn as_kilowatt_hours(&self) -> f64
pub fn as_kilowatt_hours(&self) -> f64
Convert this Energy into a floating point value in kilowatt-hours (kWh)
Trait Implementations
sourceimpl From<TorqueEnergy> for Energy
impl From<TorqueEnergy> for Energy
sourcefn from(t: TorqueEnergy) -> Energy
fn from(t: TorqueEnergy) -> Energy
Performs the conversion.
sourceimpl Measurement for Energy
impl Measurement for Energy
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<Energy> for Energy
impl PartialOrd<Energy> for Energy
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 Energy
impl Eq for Energy
Auto Trait Implementations
impl RefUnwindSafe for Energy
impl Send for Energy
impl Sync for Energy
impl Unpin for Energy
impl UnwindSafe for Energy
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