|
1 |
| -/// The `Measurement` trait and the `implement_measurement!` macro |
2 |
| -/// provides a common way for various measurements to be implemented. |
3 |
| -/// |
4 |
| -/// # Example |
5 |
| -/// ``` |
6 |
| -/// // Importing the `implement_measurement` macro from the external crate is important |
7 |
| -/// #[macro_use] |
8 |
| -/// extern crate measurements; |
9 |
| -/// |
10 |
| -/// use measurements::measurement::*; |
11 |
| -/// |
12 |
| -/// struct Cubits { |
13 |
| -/// forearms: f64 |
14 |
| -/// } |
15 |
| -/// |
16 |
| -/// impl Measurement for Cubits { |
17 |
| -/// fn get_base_units(&self) -> f64 { |
18 |
| -/// self.forearms |
19 |
| -/// } |
20 |
| -/// |
21 |
| -/// fn from_base_units(units: f64) -> Self { |
22 |
| -/// Cubits { forearms: units } |
23 |
| -/// } |
24 |
| -/// } |
25 |
| -/// |
26 |
| -/// // Invoke the macro to automatically implement Add, Sub, etc... |
27 |
| -/// implement_measurement! { Cubits } |
28 |
| -/// |
29 |
| -/// // The main function here is only included to make doc tests compile. |
30 |
| -/// // You should't need it in your own code. |
31 |
| -/// fn main() { } |
32 |
| -/// ``` |
33 | 1 | #[macro_use]
|
34 |
| -pub mod measurement; |
| 2 | +mod measurement; |
| 3 | +pub use measurement::Measurement; |
35 | 4 |
|
36 |
| -/// The `Length` struct can be used to deal with lengths in a common way. |
37 |
| -/// Common metric and imperial units are supported. |
38 |
| -/// |
39 |
| -/// # Example |
40 |
| -/// |
41 |
| -/// ``` |
42 |
| -/// use measurements::length::Length; |
43 |
| -/// |
44 |
| -/// let football_field = Length::from_yards(100.0); |
45 |
| -/// let meters = football_field.as_meters(); |
46 |
| -/// println!("There are {} meters in a football field.", meters); |
47 |
| -/// ``` |
48 | 5 | #[allow(dead_code)]
|
49 |
| -pub mod length; |
| 6 | +mod length; |
| 7 | +pub use length::Length; |
50 | 8 |
|
51 |
| -/// The `Temperature` struct can be used to deal with temperatures in a common way. |
52 |
| -/// |
53 |
| -/// # Example |
54 |
| -/// |
55 |
| -/// ``` |
56 |
| -/// use measurements::temperature::Temperature; |
57 |
| -/// |
58 |
| -/// let boiling_water = Temperature::from_celsius(100.0); |
59 |
| -/// let fahrenheit = boiling_water.as_fahrenheit(); |
60 |
| -/// println!("Boiling water measures at {} degrees fahrenheit.", fahrenheit); |
61 |
| -/// ``` |
62 | 9 | #[allow(dead_code)]
|
63 |
| -pub mod temperature; |
| 10 | +mod temperature; |
| 11 | +pub use temperature::Temperature; |
64 | 12 |
|
65 |
| -/// The `Weight` struct can be used to deal with weights in a common way. |
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 |
| -/// ``` |
77 | 13 | #[allow(dead_code)]
|
78 |
| -pub mod weight; |
| 14 | +mod weight; |
| 15 | +pub use weight::Weight; |
79 | 16 |
|
80 | 17 | // Include when running tests, but don't export them
|
81 | 18 | #[cfg(test)]
|
|
0 commit comments