pub enum Temperature {
Celsius,
Fahrenheit,
Kelvin,
}
Expand description
A list of different units of temperature.
Variants§
Celsius
SI Temperature Unit commonly used nearly all over the world.
Fahrenheit
Temperature Unit of the Imperial System.
Kelvin
SI Temperature Unit commonly used in a scientific context.
Implementations§
Source§impl Temperature
impl Temperature
Sourcepub fn convert(&self, target_temperature: Temperature, value: f64) -> f64
pub fn convert(&self, target_temperature: Temperature, value: f64) -> f64
Converts from one temperature unit to another.
§Examples
use crate::temperature::Temperature;
let temp_unit = Temperature::Celsius;
let temp = 0.0;
let converted_temp = temp_unit.convert(Temperature::Kelvin, temp);
assert_eq!(273.15, converted_temp);
Trait Implementations§
Source§impl Clone for Temperature
impl Clone for Temperature
Source§fn clone(&self) -> Temperature
fn clone(&self) -> Temperature
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Temperature
impl Debug for Temperature
Source§impl<'de> Deserialize<'de> for Temperature
impl<'de> Deserialize<'de> for Temperature
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for Temperature
impl Display for Temperature
Source§impl FromStr for Temperature
impl FromStr for Temperature
Source§impl Ord for Temperature
impl Ord for Temperature
Source§fn cmp(&self, other: &Temperature) -> Ordering
fn cmp(&self, other: &Temperature) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for Temperature
impl PartialEq for Temperature
Source§impl PartialOrd for Temperature
impl PartialOrd for Temperature
Source§impl Serialize for Temperature
impl Serialize for Temperature
Source§impl ValueEnum for Temperature
impl ValueEnum for Temperature
impl Copy for Temperature
impl Eq for Temperature
impl StructuralPartialEq for Temperature
Auto Trait Implementations§
impl Freeze for Temperature
impl RefUnwindSafe for Temperature
impl Send for Temperature
impl Sync for Temperature
impl Unpin for Temperature
impl UnwindSafe for Temperature
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.