Skip to content

Commit 0907cc6

Browse files
author
James O'Cull
committed
Updated docs for weights.
1 parent 1684854 commit 0907cc6

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Currently available units:
88

99
- Length
1010
- Temperature
11+
- Weight
1112

1213
### Example
1314

@@ -25,6 +26,7 @@ extern crate measurements;
2526

2627
use measurements::length::Length;
2728
use measurements::temperature::Temperature;
29+
use measurements::weight::Weight;
2830

2931
let football_field = Length::from_yards(100.0);
3032
let meters = football_field.as_meters();
@@ -33,4 +35,9 @@ println!("There are {} meters in a football field.", meters);
3335
let boiling_water = Temperature::from_celsius(100.0);
3436
let fahrenheit = boiling_water.as_fahrenheit();
3537
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);
3643
```

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,18 @@ pub mod length;
6262
#[allow(dead_code)]
6363
pub mod temperature;
6464

65-
/// TODO: Provide docs and examples for this.
65+
/// The `Weight` struct can be used to deal with weights in a common way.
6666
///
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+
/// ```
6777
#[allow(dead_code)]
6878
pub mod weight;
6979

0 commit comments

Comments
 (0)