@@ -110,6 +110,25 @@ impl Measurement for Temperature {
110
110
fn from_base_units ( degrees_kelvin : f64 ) -> Self {
111
111
Self :: from_kelvin ( degrees_kelvin)
112
112
}
113
+
114
+ fn get_base_units_name ( & self ) -> & ' static str {
115
+ "K"
116
+ }
117
+
118
+ }
119
+
120
+ impl Measurement for TemperatureDelta {
121
+ fn get_base_units ( & self ) -> f64 {
122
+ self . kelvin_degrees
123
+ }
124
+
125
+ fn from_base_units ( kelvin_degrees : f64 ) -> Self {
126
+ Self :: from_kelvin ( kelvin_degrees)
127
+ }
128
+
129
+ fn get_base_units_name ( & self ) -> & ' static str {
130
+ "K"
131
+ }
113
132
}
114
133
115
134
impl :: std:: ops:: Add < TemperatureDelta > for Temperature {
@@ -162,18 +181,5 @@ impl ::std::cmp::PartialOrd for TemperatureDelta {
162
181
}
163
182
}
164
183
165
- impl :: std:: fmt:: Display for Temperature {
166
- fn fmt ( & self , f : & mut :: std:: fmt:: Formatter ) -> :: std:: fmt:: Result {
167
- let p = f. precision ( ) . unwrap_or ( 1 ) ;
168
- let w = f. width ( ) . unwrap_or ( 0 ) ;
169
- write ! ( f, "{temp:width$.prec$}\u{00A0} \u{00B0} C" , prec=p, width=w, temp=self . as_celsius( ) )
170
- }
171
- }
172
-
173
- impl :: std:: fmt:: Display for TemperatureDelta {
174
- fn fmt ( & self , f : & mut :: std:: fmt:: Formatter ) -> :: std:: fmt:: Result {
175
- let p = f. precision ( ) . unwrap_or ( 1 ) ;
176
- let w = f. width ( ) . unwrap_or ( 0 ) ;
177
- write ! ( f, "{temp:width$.prec$}\u{00A0} \u{00B0} C" , prec=p, width=w, temp=self . as_celsius( ) )
178
- }
179
- }
184
+ implement_display ! ( Temperature ) ;
185
+ implement_display ! ( TemperatureDelta ) ;
0 commit comments