11use super :: measurement:: * ;
2- use length;
3- use volume;
2+ use super :: * ;
43
54const SQUARE_METER_ACRE_FACTOR : f64 = 4046.86 ;
65
@@ -33,47 +32,59 @@ impl Area {
3332 }
3433
3534 pub fn from_square_nanometers ( square_nanometers : f64 ) -> Self {
36- Self :: from_square_meters ( square_nanometers / ( length:: METER_NANOMETER_FACTOR * length:: METER_NANOMETER_FACTOR ) )
35+ Self :: from_square_meters (
36+ square_nanometers / ( length:: METER_NANOMETER_FACTOR * length:: METER_NANOMETER_FACTOR ) ,
37+ )
3738 }
3839
3940 pub fn from_square_nanometres ( square_nanometres : f64 ) -> Self {
4041 Self :: from_square_nanometers ( square_nanometres)
4142 }
4243
4344 pub fn from_square_micrometers ( square_micrometers : f64 ) -> Self {
44- Self :: from_square_meters ( square_micrometers / ( length:: METER_MICROMETER_FACTOR * length:: METER_MICROMETER_FACTOR ) )
45+ Self :: from_square_meters (
46+ square_micrometers / ( length:: METER_MICROMETER_FACTOR * length:: METER_MICROMETER_FACTOR ) ,
47+ )
4548 }
4649
4750 pub fn from_square_micrometres ( square_micrometres : f64 ) -> Self {
4851 Self :: from_square_micrometers ( square_micrometres)
4952 }
5053
5154 pub fn from_square_millimeters ( square_millimeters : f64 ) -> Self {
52- Self :: from_square_meters ( square_millimeters / ( length:: METER_MILLIMETER_FACTOR * length:: METER_MILLIMETER_FACTOR ) )
55+ Self :: from_square_meters (
56+ square_millimeters / ( length:: METER_MILLIMETER_FACTOR * length:: METER_MILLIMETER_FACTOR ) ,
57+ )
5358 }
5459
5560 pub fn from_square_millimetres ( square_millimetres : f64 ) -> Self {
5661 Self :: from_square_millimeters ( square_millimetres)
5762 }
5863
5964 pub fn from_square_centimeters ( square_centimeters : f64 ) -> Self {
60- Self :: from_square_meters ( square_centimeters / ( length:: METER_CENTIMETER_FACTOR * length:: METER_CENTIMETER_FACTOR ) )
65+ Self :: from_square_meters (
66+ square_centimeters / ( length:: METER_CENTIMETER_FACTOR * length:: METER_CENTIMETER_FACTOR ) ,
67+ )
6168 }
6269
6370 pub fn from_square_centimetres ( square_centimetres : f64 ) -> Self {
6471 Self :: from_square_centimeters ( square_centimetres)
6572 }
6673
6774 pub fn from_square_decameters ( square_decameters : f64 ) -> Self {
68- Self :: from_square_meters ( square_decameters / ( length:: METER_DECAMETER_FACTOR * length:: METER_DECAMETER_FACTOR ) )
75+ Self :: from_square_meters (
76+ square_decameters / ( length:: METER_DECAMETER_FACTOR * length:: METER_DECAMETER_FACTOR ) ,
77+ )
6978 }
7079
7180 pub fn from_square_decametres ( square_decametres : f64 ) -> Self {
7281 Self :: from_square_decameters ( square_decametres)
7382 }
7483
7584 pub fn from_square_hectometers ( square_hectometers : f64 ) -> Self {
76- Self :: from_square_meters ( square_hectometers / ( length:: METER_HECTOMETER_FACTOR * length:: METER_HECTOMETER_FACTOR ) )
85+ Self :: from_square_meters (
86+ square_hectometers / ( length:: METER_HECTOMETER_FACTOR * length:: METER_HECTOMETER_FACTOR ) ,
87+ )
7788 }
7889
7990 pub fn from_square_hectometres ( square_hectometres : f64 ) -> Self {
@@ -85,7 +96,9 @@ impl Area {
8596 }
8697
8798 pub fn from_square_kilometers ( square_kilometers : f64 ) -> Self {
88- Self :: from_square_meters ( square_kilometers / ( length:: METER_KILOMETER_FACTOR * length:: METER_KILOMETER_FACTOR ) )
99+ Self :: from_square_meters (
100+ square_kilometers / ( length:: METER_KILOMETER_FACTOR * length:: METER_KILOMETER_FACTOR ) ,
101+ )
89102 }
90103
91104 pub fn from_square_kilometres ( square_kilometres : f64 ) -> Self {
@@ -94,52 +107,60 @@ impl Area {
94107
95108 // Inputs, imperial
96109 pub fn from_square_inches ( square_inches : f64 ) -> Self {
97- Self :: from_square_meters ( square_inches / ( length:: METER_INCH_FACTOR * length:: METER_INCH_FACTOR ) )
110+ Self :: from_square_meters (
111+ square_inches / ( length:: METER_INCH_FACTOR * length:: METER_INCH_FACTOR ) ,
112+ )
98113 }
99114
100115 pub fn from_square_feet ( square_feet : f64 ) -> Self {
101- Self :: from_square_meters ( square_feet / ( length:: METER_FEET_FACTOR * length:: METER_FEET_FACTOR ) )
116+ Self :: from_square_meters (
117+ square_feet / ( length:: METER_FEET_FACTOR * length:: METER_FEET_FACTOR ) ,
118+ )
102119 }
103120
104121 pub fn from_square_yards ( square_yards : f64 ) -> Self {
105- Self :: from_square_meters ( square_yards / ( length:: METER_YARD_FACTOR * length:: METER_YARD_FACTOR ) )
122+ Self :: from_square_meters (
123+ square_yards / ( length:: METER_YARD_FACTOR * length:: METER_YARD_FACTOR ) ,
124+ )
106125 }
107126
108127 pub fn from_acres ( acres : f64 ) -> Self {
109128 Self :: from_square_meters ( acres / SQUARE_METER_ACRE_FACTOR )
110129 }
111130
112131 pub fn from_square_miles ( square_miles : f64 ) -> Self {
113- Self :: from_square_meters ( square_miles / ( length:: METER_MILE_FACTOR * length:: METER_MILE_FACTOR ) )
132+ Self :: from_square_meters (
133+ square_miles / ( length:: METER_MILE_FACTOR * length:: METER_MILE_FACTOR ) ,
134+ )
114135 }
115136
116137 // Outputs, metric
117138 pub fn as_square_nanometers ( & self ) -> f64 {
118- self . square_meters * length:: METER_NANOMETER_FACTOR * length:: METER_NANOMETER_FACTOR
139+ self . square_meters * ( length:: METER_NANOMETER_FACTOR * length:: METER_NANOMETER_FACTOR )
119140 }
120141
121142 pub fn as_square_nanometres ( & self ) -> f64 {
122143 self . as_square_nanometers ( )
123144 }
124145
125146 pub fn as_square_micrometers ( & self ) -> f64 {
126- self . square_meters * length:: METER_MICROMETER_FACTOR * length:: METER_MICROMETER_FACTOR
147+ self . square_meters * ( length:: METER_MICROMETER_FACTOR * length:: METER_MICROMETER_FACTOR )
127148 }
128149
129150 pub fn as_square_micrometres ( & self ) -> f64 {
130151 self . as_square_micrometers ( )
131152 }
132153
133154 pub fn as_square_millimeters ( & self ) -> f64 {
134- self . square_meters * length:: METER_MILLIMETER_FACTOR * length:: METER_MILLIMETER_FACTOR
155+ self . square_meters * ( length:: METER_MILLIMETER_FACTOR * length:: METER_MILLIMETER_FACTOR )
135156 }
136157
137158 pub fn as_square_millimetres ( & self ) -> f64 {
138159 self . as_square_millimeters ( )
139160 }
140161
141162 pub fn as_square_centimeters ( & self ) -> f64 {
142- self . square_meters * length:: METER_CENTIMETER_FACTOR * length:: METER_CENTIMETER_FACTOR
163+ self . square_meters * ( length:: METER_CENTIMETER_FACTOR * length:: METER_CENTIMETER_FACTOR )
143164 }
144165
145166 pub fn as_square_centimetres ( & self ) -> f64 {
@@ -155,15 +176,15 @@ impl Area {
155176 }
156177
157178 pub fn as_square_decameters ( & self ) -> f64 {
158- self . square_meters * length:: METER_DECAMETER_FACTOR * length:: METER_DECAMETER_FACTOR
179+ self . square_meters * ( length:: METER_DECAMETER_FACTOR * length:: METER_DECAMETER_FACTOR )
159180 }
160181
161182 pub fn as_square_decametres ( & self ) -> f64 {
162183 self . as_square_decameters ( )
163184 }
164185
165186 pub fn as_square_hectometers ( & self ) -> f64 {
166- self . square_meters * length:: METER_HECTOMETER_FACTOR * length:: METER_HECTOMETER_FACTOR
187+ self . square_meters * ( length:: METER_HECTOMETER_FACTOR * length:: METER_HECTOMETER_FACTOR )
167188 }
168189
169190 pub fn as_square_hectometres ( & self ) -> f64 {
@@ -175,7 +196,7 @@ impl Area {
175196 }
176197
177198 pub fn as_square_kilometers ( & self ) -> f64 {
178- self . square_meters * length:: METER_KILOMETER_FACTOR * length:: METER_KILOMETER_FACTOR
199+ self . square_meters * ( length:: METER_KILOMETER_FACTOR * length:: METER_KILOMETER_FACTOR )
179200 }
180201
181202 pub fn as_square_kilometres ( & self ) -> f64 {
@@ -184,41 +205,50 @@ impl Area {
184205
185206 // Outputs, imperial
186207 pub fn as_square_inches ( & self ) -> f64 {
187- self . square_meters * length:: METER_INCH_FACTOR * length:: METER_INCH_FACTOR
208+ self . square_meters * ( length:: METER_INCH_FACTOR * length:: METER_INCH_FACTOR )
188209 }
189210
190211 pub fn as_square_feet ( & self ) -> f64 {
191- self . square_meters * length:: METER_FEET_FACTOR * length:: METER_FEET_FACTOR
212+ self . square_meters * ( length:: METER_FEET_FACTOR * length:: METER_FEET_FACTOR )
192213 }
193214
194215 pub fn as_square_yards ( & self ) -> f64 {
195- self . square_meters * length:: METER_YARD_FACTOR * length:: METER_YARD_FACTOR
216+ self . square_meters * ( length:: METER_YARD_FACTOR * length:: METER_YARD_FACTOR )
196217 }
197218
198219 pub fn as_acres ( & self ) -> f64 {
199220 self . square_meters * SQUARE_METER_ACRE_FACTOR
200221 }
201222
202223 pub fn as_square_miles ( & self ) -> f64 {
203- self . square_meters * length:: METER_MILE_FACTOR * length:: METER_MILE_FACTOR
224+ self . square_meters * ( length:: METER_MILE_FACTOR * length:: METER_MILE_FACTOR )
204225 }
205226}
206227
207228/// Area / Length = Length
208- impl :: std:: ops:: Div < length :: Length > for Area {
209- type Output = length :: Length ;
229+ impl :: std:: ops:: Div < Length > for Area {
230+ type Output = Length ;
210231
211- fn div ( self , rhs : length :: Length ) -> length :: Length {
212- length :: Length :: from_meters ( self . as_square_meters ( ) / rhs. as_meters ( ) )
232+ fn div ( self , rhs : Length ) -> Length {
233+ Length :: from_meters ( self . as_square_meters ( ) / rhs. as_meters ( ) )
213234 }
214235}
215236
216237/// Area * Length = Volume
217- impl :: std:: ops:: Mul < length :: Length > for Area {
218- type Output = volume :: Volume ;
238+ impl :: std:: ops:: Mul < Length > for Area {
239+ type Output = Volume ;
219240
220- fn mul ( self , rhs : length:: Length ) -> volume:: Volume {
221- volume:: Volume :: from_cubic_meters ( self . as_square_meters ( ) * rhs. as_meters ( ) )
241+ fn mul ( self , rhs : Length ) -> Volume {
242+ Volume :: from_cubic_meters ( self . as_square_meters ( ) * rhs. as_meters ( ) )
243+ }
244+ }
245+
246+ /// Area * Pressure = Force
247+ impl :: std:: ops:: Mul < Pressure > for Area {
248+ type Output = Force ;
249+
250+ fn mul ( self , rhs : Pressure ) -> Force {
251+ Force :: from_newtons ( self . as_square_meters ( ) * rhs. as_pascals ( ) )
222252 }
223253}
224254
0 commit comments