File tree Expand file tree Collapse file tree 23 files changed +206
-206
lines changed Expand file tree Collapse file tree 23 files changed +206
-206
lines changed Original file line number Diff line number Diff line change @@ -69,17 +69,17 @@ impl Acceleration {
69
69
}
70
70
71
71
impl Measurement for Acceleration {
72
+ fn get_base_units_name ( & self ) -> & ' static str {
73
+ "m/s\u{00B2} "
74
+ }
75
+
72
76
fn as_base_units ( & self ) -> f64 {
73
77
self . meters_per_second_per_second
74
78
}
75
79
76
80
fn from_base_units ( units : f64 ) -> Self {
77
81
Self :: from_meters_per_second_per_second ( units)
78
82
}
79
-
80
- fn get_base_units_name ( & self ) -> & ' static str {
81
- "m/s\u{00B2} "
82
- }
83
83
}
84
84
85
85
#[ cfg( feature = "from_str" ) ]
Original file line number Diff line number Diff line change @@ -90,17 +90,17 @@ impl Angle {
90
90
}
91
91
92
92
impl Measurement for Angle {
93
+ fn get_base_units_name ( & self ) -> & ' static str {
94
+ "rad"
95
+ }
96
+
93
97
fn as_base_units ( & self ) -> f64 {
94
98
self . radians
95
99
}
96
100
97
101
fn from_base_units ( units : f64 ) -> Self {
98
102
Self :: from_radians ( units)
99
103
}
100
-
101
- fn get_base_units_name ( & self ) -> & ' static str {
102
- "rad"
103
- }
104
104
}
105
105
106
106
#[ cfg( feature = "from_str" ) ]
Original file line number Diff line number Diff line change @@ -58,17 +58,17 @@ impl AngularVelocity {
58
58
}
59
59
60
60
impl Measurement for AngularVelocity {
61
+ fn get_base_units_name ( & self ) -> & ' static str {
62
+ "rad/s"
63
+ }
64
+
61
65
fn as_base_units ( & self ) -> f64 {
62
66
self . radians_per_second
63
67
}
64
68
65
69
fn from_base_units ( units : f64 ) -> Self {
66
70
Self :: from_radians_per_second ( units)
67
71
}
68
-
69
- fn get_base_units_name ( & self ) -> & ' static str {
70
- "rad/s"
71
- }
72
72
}
73
73
74
74
#[ cfg( feature = "from_str" ) ]
Original file line number Diff line number Diff line change @@ -277,18 +277,6 @@ impl Area {
277
277
}
278
278
279
279
impl Measurement for Area {
280
- fn as_base_units ( & self ) -> f64 {
281
- self . square_meters
282
- }
283
-
284
- fn from_base_units ( units : f64 ) -> Self {
285
- Self :: from_square_meters ( units)
286
- }
287
-
288
- fn get_base_units_name ( & self ) -> & ' static str {
289
- "m\u{00B2} "
290
- }
291
-
292
280
fn get_appropriate_units ( & self ) -> ( & ' static str , f64 ) {
293
281
// Smallest to largest
294
282
let list = [
@@ -303,6 +291,18 @@ impl Measurement for Area {
303
291
] ;
304
292
self . pick_appropriate_units ( & list)
305
293
}
294
+
295
+ fn get_base_units_name ( & self ) -> & ' static str {
296
+ "m\u{00B2} "
297
+ }
298
+
299
+ fn as_base_units ( & self ) -> f64 {
300
+ self . square_meters
301
+ }
302
+
303
+ fn from_base_units ( units : f64 ) -> Self {
304
+ Self :: from_square_meters ( units)
305
+ }
306
306
}
307
307
308
308
#[ cfg( feature = "from_str" ) ]
Original file line number Diff line number Diff line change @@ -64,18 +64,6 @@ impl Current {
64
64
}
65
65
66
66
impl Measurement for Current {
67
- fn as_base_units ( & self ) -> f64 {
68
- self . amperes
69
- }
70
-
71
- fn from_base_units ( units : f64 ) -> Self {
72
- Self :: from_amperes ( units)
73
- }
74
-
75
- fn get_base_units_name ( & self ) -> & ' static str {
76
- "A"
77
- }
78
-
79
67
fn get_appropriate_units ( & self ) -> ( & ' static str , f64 ) {
80
68
// Smallest to Largest
81
69
let list = [
@@ -94,6 +82,18 @@ impl Measurement for Current {
94
82
] ;
95
83
self . pick_appropriate_units ( & list)
96
84
}
85
+
86
+ fn get_base_units_name ( & self ) -> & ' static str {
87
+ "A"
88
+ }
89
+
90
+ fn as_base_units ( & self ) -> f64 {
91
+ self . amperes
92
+ }
93
+
94
+ fn from_base_units ( units : f64 ) -> Self {
95
+ Self :: from_amperes ( units)
96
+ }
97
97
}
98
98
99
99
implement_measurement ! { Current }
Original file line number Diff line number Diff line change @@ -139,18 +139,6 @@ impl Data {
139
139
}
140
140
141
141
impl Measurement for Data {
142
- fn as_base_units ( & self ) -> f64 {
143
- self . octets
144
- }
145
-
146
- fn from_base_units ( units : f64 ) -> Self {
147
- Self :: from_octets ( units)
148
- }
149
-
150
- fn get_base_units_name ( & self ) -> & ' static str {
151
- "octets"
152
- }
153
-
154
142
fn get_appropriate_units ( & self ) -> ( & ' static str , f64 ) {
155
143
// Smallest to largest
156
144
let list = [
@@ -164,6 +152,18 @@ impl Measurement for Data {
164
152
] ;
165
153
self . pick_appropriate_units ( & list)
166
154
}
155
+
156
+ fn get_base_units_name ( & self ) -> & ' static str {
157
+ "octets"
158
+ }
159
+
160
+ fn as_base_units ( & self ) -> f64 {
161
+ self . octets
162
+ }
163
+
164
+ fn from_base_units ( units : f64 ) -> Self {
165
+ Self :: from_octets ( units)
166
+ }
167
167
}
168
168
169
169
implement_measurement ! { Data }
Original file line number Diff line number Diff line change @@ -110,17 +110,17 @@ impl ::std::ops::Mul<Volume> for Density {
110
110
}
111
111
112
112
impl Measurement for Density {
113
+ fn get_base_units_name ( & self ) -> & ' static str {
114
+ "kg/m\u{00B3} "
115
+ }
116
+
113
117
fn as_base_units ( & self ) -> f64 {
114
118
self . kilograms_per_cubic_meter
115
119
}
116
120
117
121
fn from_base_units ( units : f64 ) -> Self {
118
122
Self :: from_kilograms_per_cubic_meter ( units)
119
123
}
120
-
121
- fn get_base_units_name ( & self ) -> & ' static str {
122
- "kg/m\u{00B3} "
123
- }
124
124
}
125
125
126
126
implement_measurement ! { Density }
Original file line number Diff line number Diff line change @@ -82,18 +82,6 @@ impl Energy {
82
82
}
83
83
84
84
impl Measurement for Energy {
85
- fn as_base_units ( & self ) -> f64 {
86
- self . joules
87
- }
88
-
89
- fn from_base_units ( units : f64 ) -> Self {
90
- Self :: from_joules ( units)
91
- }
92
-
93
- fn get_base_units_name ( & self ) -> & ' static str {
94
- "J"
95
- }
96
-
97
85
fn get_appropriate_units ( & self ) -> ( & ' static str , f64 ) {
98
86
// Smallest to Largest
99
87
let list = [
@@ -112,6 +100,18 @@ impl Measurement for Energy {
112
100
] ;
113
101
self . pick_appropriate_units ( & list)
114
102
}
103
+
104
+ fn get_base_units_name ( & self ) -> & ' static str {
105
+ "J"
106
+ }
107
+
108
+ fn as_base_units ( & self ) -> f64 {
109
+ self . joules
110
+ }
111
+
112
+ fn from_base_units ( units : f64 ) -> Self {
113
+ Self :: from_joules ( units)
114
+ }
115
115
}
116
116
117
117
implement_measurement ! { Energy }
Original file line number Diff line number Diff line change @@ -107,18 +107,6 @@ impl Force {
107
107
}
108
108
109
109
impl Measurement for Force {
110
- fn as_base_units ( & self ) -> f64 {
111
- self . newtons
112
- }
113
-
114
- fn from_base_units ( units : f64 ) -> Self {
115
- Self :: from_newtons ( units)
116
- }
117
-
118
- fn get_base_units_name ( & self ) -> & ' static str {
119
- "N"
120
- }
121
-
122
110
fn get_appropriate_units ( & self ) -> ( & ' static str , f64 ) {
123
111
// Smallest to largest
124
112
let list = [
@@ -133,6 +121,18 @@ impl Measurement for Force {
133
121
] ;
134
122
self . pick_appropriate_units ( & list)
135
123
}
124
+
125
+ fn get_base_units_name ( & self ) -> & ' static str {
126
+ "N"
127
+ }
128
+
129
+ fn as_base_units ( & self ) -> f64 {
130
+ self . newtons
131
+ }
132
+
133
+ fn from_base_units ( units : f64 ) -> Self {
134
+ Self :: from_newtons ( units)
135
+ }
136
136
}
137
137
138
138
implement_measurement ! { Force }
Original file line number Diff line number Diff line change @@ -131,18 +131,6 @@ impl Frequency {
131
131
}
132
132
133
133
impl Measurement for Frequency {
134
- fn as_base_units ( & self ) -> f64 {
135
- self . hertz
136
- }
137
-
138
- fn from_base_units ( units : f64 ) -> Self {
139
- Self :: from_hertz ( units)
140
- }
141
-
142
- fn get_base_units_name ( & self ) -> & ' static str {
143
- "Hz"
144
- }
145
-
146
134
fn get_appropriate_units ( & self ) -> ( & ' static str , f64 ) {
147
135
// Smallest to largest
148
136
let list = [
@@ -157,6 +145,18 @@ impl Measurement for Frequency {
157
145
] ;
158
146
self . pick_appropriate_units ( & list)
159
147
}
148
+
149
+ fn get_base_units_name ( & self ) -> & ' static str {
150
+ "Hz"
151
+ }
152
+
153
+ fn as_base_units ( & self ) -> f64 {
154
+ self . hertz
155
+ }
156
+
157
+ fn from_base_units ( units : f64 ) -> Self {
158
+ Self :: from_hertz ( units)
159
+ }
160
160
}
161
161
162
162
implement_measurement ! { Frequency }
You can’t perform that action at this time.
0 commit comments