File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
Hurray! Now you can work with units of measure in a headache-free way.
6
6
7
- Currently only ` Length ` is available, but I am planning to add more shortly.
7
+ Currently available units:
8
+
9
+ - Length
10
+ - Temperature
8
11
9
12
### Example
10
13
11
14
In your Cargo.toml...
12
15
13
16
```
14
17
[dependencies]
15
- measurements = "^0.1 .0"
18
+ measurements = "^0.2 .0"
16
19
```
17
20
18
21
In your code...
19
22
20
23
```
21
24
extern crate measurements;
22
25
23
- use measurements::length::Length;
26
+ use measurements::length::{ Length, Temperature} ;
24
27
25
28
let football_field = Length::from_yards(100.0);
26
29
let meters = football_field.as_meters();
27
30
println!("There are {} meters in a football field.", meters);
31
+
32
+ let boiling_water = Temperature::from_celsius(100.0);
33
+ let fahrenheit = boiling_water.as_fahrenheit();
34
+ println!("Boiling water measures at {} degrees fahrenheit.", fahrenheit);
28
35
```
You can’t perform that action at this time.
0 commit comments