File tree Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ pub const LBCF_KGCM_FACTOR: f64 = 0.062427973725314;
26
26
/// let mans_weight = Mass::from_stones(12.0);
27
27
/// let water_volume = mans_weight / body_density;
28
28
/// println!("{} gallons of water spilled on the floor", water_volume.as_gallons());
29
- ///}
29
+ /// }
30
30
/// ```
31
31
/// # Example2 - converting to ad-hoc units of density
32
32
///
@@ -40,9 +40,8 @@ pub const LBCF_KGCM_FACTOR: f64 = 0.062427973725314;
40
40
/// let density: Density = Mass::from_grams(3.0) / Volume:: from_litres(1.0);
41
41
/// let ounces = (density * Volume::from_quarts(1.0)).as_ounces();
42
42
/// println!("Answer is {} ounces per quart", ounces);
43
- ///}
43
+ /// }
44
44
/// ```
45
-
46
45
#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
47
46
#[ derive( Copy , Clone , Debug , Default ) ]
48
47
pub struct Density {
Original file line number Diff line number Diff line change 1
- /// The `Measurement` trait and the `implement_measurement!` macro
2
- /// provides a common way for various measurements to be implemented.
1
+ //! The `Measurement` trait and the `implement_measurement!` macro
2
+ //! provides a common way for various measurements to be implemented.
3
+ ///
4
+ /// All measurements implement this.
5
+ ///
6
+ /// It provides conversion functions to and from raw numbers.
3
7
///
4
8
/// # Example
5
9
/// ```
6
- /// #![no_std]
7
10
/// // Importing the `implement_measurement` macro from the external crate is important
8
11
/// #[macro_use]
9
12
/// extern crate measurements;
35
38
/// // You should't need it in your own code.
36
39
/// fn main() { }
37
40
/// ```
38
-
39
- #[ cfg( feature = "no-std" ) ]
40
- use core as std;
41
-
42
- #[ cfg( feature = "no-std" ) ]
43
- use core:: num:: Float ;
44
-
45
- /// All measurements implement this.
46
41
///
47
- /// It provides conversion functions to and from raw numbers.
42
+ /// *Note*: If you are in a `no_std` environment, you have to
43
+ /// `use core as std;` for the macros to run.
48
44
pub trait Measurement {
49
45
/// Returns a string containing the most appropriate units for this quantity,
50
46
/// and a floating point value representing this quantity in those units.
You can’t perform that action at this time.
0 commit comments