uom/si/
temperature_interval.rs1use crate::si::thermodynamic_temperature::ThermodynamicTemperature;
9
10quantity! {
11 quantity: TemperatureInterval; "temperature interval";
13 dimension: ISQ<
15 Z0, Z0, Z0, Z0, P1, Z0, Z0>; units {
23 @yottakelvin: prefix!(yotta); "YK", "yottakelvin", "yottakelvins";
24 @zettakelvin: prefix!(zetta); "ZK", "zettakelvin", "zettakelvins";
25 @exakelvin: prefix!(exa); "EK", "exakelvin", "exakelvins";
26 @petakelvin: prefix!(peta); "PK", "petakelvin", "petakelvins";
27 @terakelvin: prefix!(tera); "TK", "terakelvin", "terakelvins";
28 @gigakelvin: prefix!(giga); "GK", "gigakelvin", "gigakelvins";
29 @megakelvin: prefix!(mega); "MK", "megakelvin", "megakelvins";
30 @kilokelvin: prefix!(kilo); "kK", "kilokelvin", "kilokelvins";
31 @hectokelvin: prefix!(hecto); "hK", "hectokelvin", "hectokelvins";
32 @decakelvin: prefix!(deca); "daK", "decakelvin", "decakelvins";
33 @kelvin: prefix!(none); "K", "kelvin", "kelvins";
38 @decikelvin: prefix!(deci); "dK", "decikelvin", "decikelvins";
39 @centikelvin: prefix!(centi); "cK", "centikelvin", "centikelvins";
40 @millikelvin: prefix!(milli); "mK", "millikelvin", "millikelvins";
41 @microkelvin: prefix!(micro); "µK", "microkelvin", "microkelvins";
42 @nanokelvin: prefix!(nano); "nK", "nanokelvin", "nanokelvins";
43 @picokelvin: prefix!(pico); "pK", "picokelvin", "picokelvins";
44 @femtokelvin: prefix!(femto); "fK", "femtokelvin", "femtokelvins";
45 @attokelvin: prefix!(atto); "aK", "attokelvin", "attokelvins";
46 @zeptokelvin: prefix!(zepto); "zK", "zeptokelvin", "zeptokelvins";
47 @yoctokelvin: prefix!(yocto); "yK", "yoctokelvin", "yoctokelvins";
48
49 @degree_celsius: 1.0_E0; "°C", "degree Celsius", "degrees Celsius";
50 @degree_fahrenheit: 5.0_E0 / 9.0_E0; "°F", "degree Fahrenheit", "degrees Fahrenheit";
51 @degree_rankine: 5.0_E0 / 9.0_E0; "°R", "degree Rankine", "degrees Rankine";
52 }
53}
54
55#[cfg(feature = "autoconvert")]
56impl<Ul, Ur, V> crate::lib::ops::Add<ThermodynamicTemperature<Ur, V>> for TemperatureInterval<Ul, V>
57where
58 Ul: super::Units<V> + ?Sized,
59 Ur: super::Units<V> + ?Sized,
60 V: crate::num::Num + crate::Conversion<V>,
61{
62 type Output = ThermodynamicTemperature<Ul, V>;
63
64 #[inline(always)]
65 fn add(self, rhs: ThermodynamicTemperature<Ur, V>) -> Self::Output {
66 super::Quantity {
67 dimension: crate::lib::marker::PhantomData,
68 units: crate::lib::marker::PhantomData,
69 value: self.value + super::change_base::<Dimension, Ul, Ur, V>(&rhs.value),
70 }
71 }
72}
73
74#[cfg(not(feature = "autoconvert"))]
75impl<U, V> crate::lib::ops::Add<ThermodynamicTemperature<U, V>> for TemperatureInterval<U, V>
76where
77 U: super::Units<V> + ?Sized,
78 V: crate::num::Num + crate::Conversion<V>,
79{
80 type Output = ThermodynamicTemperature<U, V>;
81
82 #[inline(always)]
83 fn add(self, rhs: ThermodynamicTemperature<U, V>) -> Self::Output {
84 super::Quantity {
85 dimension: crate::lib::marker::PhantomData,
86 units: crate::lib::marker::PhantomData,
87 value: self.value + rhs.value,
88 }
89 }
90}
91
92#[cfg(test)]
93mod tests {
94 storage_types! {
95 use crate::si::quantities::*;
96 use crate::si::temperature_interval as ti;
97 use crate::si::thermodynamic_temperature as tt;
98 use crate::tests::{A, Test};
99
100 quickcheck! {
101 #[allow(trivial_casts)]
102 fn add(l: A<V>, r: A<V>) -> bool {
103 Test::eq(&ThermodynamicTemperature::<V>::new::<tt::kelvin>(&*l + &*r),
104 &(TemperatureInterval::<V>::new::<ti::kelvin>((*l).clone())
105 + ThermodynamicTemperature::<V>::new::<tt::kelvin>((*r).clone())))
106 }
107 }
108 }
109}