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;
2626/// let mans_weight = Mass::from_stones(12.0);
2727/// let water_volume = mans_weight / body_density;
2828/// println!("{} gallons of water spilled on the floor", water_volume.as_gallons());
29- ///}
29+ /// }
3030/// ```
3131/// # Example2 - converting to ad-hoc units of density
3232///
@@ -40,9 +40,8 @@ pub const LBCF_KGCM_FACTOR: f64 = 0.062427973725314;
4040/// let density: Density = Mass::from_grams(3.0) / Volume:: from_litres(1.0);
4141/// let ounces = (density * Volume::from_quarts(1.0)).as_ounces();
4242/// println!("Answer is {} ounces per quart", ounces);
43- ///}
43+ /// }
4444/// ```
45-
4645#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
4746#[ derive( Copy , Clone , Debug , Default ) ]
4847pub 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.
37///
48/// # Example
59/// ```
6- /// #![no_std]
710/// // Importing the `implement_measurement` macro from the external crate is important
811/// #[macro_use]
912/// extern crate measurements;
3538/// // You should't need it in your own code.
3639/// fn main() { }
3740/// ```
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.
4641///
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.
4844pub trait Measurement {
4945 /// Returns a string containing the most appropriate units for this quantity,
5046 /// and a floating point value representing this quantity in those units.
You can’t perform that action at this time.
0 commit comments