Struct measurements::temperature::Temperature
source · [−]pub struct Temperature { /* private fields */ }
Expand description
The Temperature
struct can be used to deal with absolute temperatures in
a common way.
Example
use measurements::Temperature;
let boiling_water = Temperature::from_celsius(100.0);
let fahrenheit = boiling_water.as_fahrenheit();
println!("Boiling water measures at {} degrees fahrenheit.", fahrenheit);
Implementations
sourceimpl Temperature
impl Temperature
sourcepub fn from_kelvin(degrees_kelvin: f64) -> Self
pub fn from_kelvin(degrees_kelvin: f64) -> Self
Create a new Temperature from a floating point value in Kelvin
sourcepub fn from_celsius(degrees_celsius: f64) -> Self
pub fn from_celsius(degrees_celsius: f64) -> Self
Create a new Temperature from a floating point value in Celsius
sourcepub fn from_fahrenheit(degrees_fahrenheit: f64) -> Self
pub fn from_fahrenheit(degrees_fahrenheit: f64) -> Self
Create a new Temperature from a floating point value in Fahrenheit
sourcepub fn from_rankine(degrees_rankine: f64) -> Self
pub fn from_rankine(degrees_rankine: f64) -> Self
Create a new Temperature from a floating point value in Rankine
sourcepub fn as_kelvin(&self) -> f64
pub fn as_kelvin(&self) -> f64
Convert this absolute Temperature to a floating point value in Kelvin
sourcepub fn as_celsius(&self) -> f64
pub fn as_celsius(&self) -> f64
Convert this absolute Temperature to a floating point value in Celsius
sourcepub fn as_fahrenheit(&self) -> f64
pub fn as_fahrenheit(&self) -> f64
Convert this absolute Temperature to a floating point value in Fahrenheit
sourcepub fn as_rankine(&self) -> f64
pub fn as_rankine(&self) -> f64
Convert this absolute Temperature to a floating point value in Rankine
Trait Implementations
sourceimpl Add<Temperature> for TemperatureDelta
impl Add<Temperature> for TemperatureDelta
type Output = Temperature
type Output = Temperature
The resulting type after applying the +
operator.
sourcefn add(self, other: Temperature) -> Temperature
fn add(self, other: Temperature) -> Temperature
Performs the +
operation. Read more
sourceimpl Add<TemperatureDelta> for Temperature
impl Add<TemperatureDelta> for Temperature
type Output = Temperature
type Output = Temperature
The resulting type after applying the +
operator.
sourcefn add(self, other: TemperatureDelta) -> Temperature
fn add(self, other: TemperatureDelta) -> Temperature
Performs the +
operation. Read more
sourceimpl Clone for Temperature
impl Clone for Temperature
sourcefn clone(&self) -> Temperature
fn clone(&self) -> Temperature
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Temperature
impl Debug for Temperature
sourceimpl Display for Temperature
impl Display for Temperature
sourceimpl Measurement for Temperature
impl Measurement for Temperature
sourcefn as_base_units(&self) -> f64
fn as_base_units(&self) -> f64
Get this quantity in the base units
sourcefn from_base_units(degrees_kelvin: f64) -> Self
fn from_base_units(degrees_kelvin: 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 PartialEq<Temperature> for Temperature
impl PartialEq<Temperature> for Temperature
sourceimpl PartialOrd<Temperature> for Temperature
impl PartialOrd<Temperature> for Temperature
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
sourceimpl Sub<Temperature> for Temperature
impl Sub<Temperature> for Temperature
type Output = TemperatureDelta
type Output = TemperatureDelta
The resulting type after applying the -
operator.
sourcefn sub(self, other: Temperature) -> TemperatureDelta
fn sub(self, other: Temperature) -> TemperatureDelta
Performs the -
operation. Read more
sourceimpl Sub<TemperatureDelta> for Temperature
impl Sub<TemperatureDelta> for Temperature
type Output = Temperature
type Output = Temperature
The resulting type after applying the -
operator.
sourcefn sub(self, other: TemperatureDelta) -> Temperature
fn sub(self, other: TemperatureDelta) -> Temperature
Performs the -
operation. Read more
impl Copy for Temperature
impl Eq for Temperature
Auto Trait Implementations
impl RefUnwindSafe for Temperature
impl Send for Temperature
impl Sync for Temperature
impl Unpin for Temperature
impl UnwindSafe for Temperature
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