File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ Currently available units:
8
8
9
9
- Length
10
10
- Temperature
11
+ - Weight
11
12
12
13
### Example
13
14
@@ -25,6 +26,7 @@ extern crate measurements;
25
26
26
27
use measurements :: length :: Length ;
27
28
use measurements :: temperature :: Temperature ;
29
+ use measurements :: weight :: Weight ;
28
30
29
31
let football_field = Length :: from_yards (100.0 );
30
32
let meters = football_field . as_meters ();
@@ -33,4 +35,9 @@ println!("There are {} meters in a football field.", meters);
33
35
let boiling_water = Temperature :: from_celsius (100.0 );
34
36
let fahrenheit = boiling_water . as_fahrenheit ();
35
37
println! (" Boiling water measures at {} degrees fahrenheit." , fahrenheit );
38
+
39
+ let metric_ton = Weight :: from_metric_tons (1.0 );
40
+ let united_states_tons = metric_ton . as_short_tons ();
41
+ let united_states_pounds = metric_ton . as_pounds ();
42
+ println! (" One metric ton is {} U.S. tons - that's {} pounds!" , united_states_tons , united_states_pounds );
36
43
```
Original file line number Diff line number Diff line change @@ -62,8 +62,18 @@ pub mod length;
62
62
#[ allow( dead_code) ]
63
63
pub mod temperature;
64
64
65
- /// TODO: Provide docs and examples for this .
65
+ /// The `Weight` struct can be used to deal with weights in a common way .
66
66
///
67
+ /// #Example
68
+ ///
69
+ /// ```
70
+ /// use measurements::weight::Weight;
71
+ ///
72
+ /// let metric_ton = Weight::from_metric_tons(1.0);
73
+ /// let united_states_tons = metric_ton.as_short_tons();
74
+ /// let united_states_pounds = metric_ton.as_pounds();
75
+ /// println!("One metric ton is {} U.S. tons - that's {} pounds!", united_states_tons, united_states_pounds);
76
+ /// ```
67
77
#[ allow( dead_code) ]
68
78
pub mod weight;
69
79
You can’t perform that action at this time.
0 commit comments