@@ -22,44 +22,51 @@ Conversions to and from different units are simple, and operator overrides allow
2222- Temperature
2323- Weight
2424- Volume
25+ - Pressure
2526
2627### Examples
2728
2829In your Cargo.toml add the dependency...
2930
30- ```
31+ ``` toml
3132[dependencies ]
32- measurements = "^0.2.1 "
33+ measurements = " ^0.3.0 "
3334```
3435
3536In your code...
3637
3738``` rust
3839extern crate measurements;
3940
40- use measurements :: {Length , Temperature , Weight , Volume };
41-
42- // Lengths!
43- let football_field = Length :: from_yards (100.0 );
44- let meters = football_field . as_meters ();
45- println! (" There are {} meters in a football field." , meters );
46-
47- /// Temperatures!
48- let boiling_water = Temperature :: from_celsius (100.0 );
49- let fahrenheit = boiling_water . as_fahrenheit ();
50- println! (" Boiling water measures at {} degrees fahrenheit." , fahrenheit );
51-
52- // Weights!
53- let metric_ton = Weight :: from_metric_tons (1.0 );
54- let united_states_tons = metric_ton . as_short_tons ();
55- let united_states_pounds = metric_ton . as_pounds ();
56- println! (" One metric ton is {} U.S. tons - that's {} pounds!" , united_states_tons , united_states_pounds );
57-
58- // Volumes!
59- let gallon = Volume :: from_gallons (1.0 );
60- let pint = Volume :: from_pints (1.0 );
61- let beers = gallon / pint ;
62- println! (" A gallon of beer will pour {} pints!" , beers );
41+ use measurements :: {Length , Pressure , Temperature , Volume , Weight };
42+
43+ fn main () {
44+ // Lengths!
45+ let football_field = Length :: from_yards (100.0 );
46+ let meters = football_field . as_meters ();
47+ println! (" There are {} meters in a football field." , meters );
48+
49+ /// Temperatures!
50+ let boiling_water = Temperature :: from_celsius (100.0 );
51+ let fahrenheit = boiling_water . as_fahrenheit ();
52+ println! (" Boiling water measures at {} degrees fahrenheit." , fahrenheit );
53+
54+ // Weights!
55+ let metric_ton = Weight :: from_metric_tons (1.0 );
56+ let united_states_tons = metric_ton . as_short_tons ();
57+ let united_states_pounds = metric_ton . as_pounds ();
58+ println! (" One metric ton is {} U.S. tons - that's {} pounds!" , united_states_tons , united_states_pounds );
59+
60+ // Volumes!
61+ let gallon = Volume :: from_gallons (1.0 );
62+ let pint = Volume :: from_pints (1.0 );
63+ let beers = gallon / pint ;
64+ println! (" A gallon of beer will pour {:.1} pints!" , beers );
65+
66+ // Pressures!
67+ let atmosphere = Pressure :: from_atmospheres (1.0 );
68+ println! (" Earth's atmosphere is usually {} psi" , atmosphere . as_psi ());
69+ }
6370```
6471
6572--------------------------------------
0 commit comments