-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ci skip] Correct macros to generate valid 2015/2018 edition code.
Doc test on the `$quantities!` macro would fail with the error `no ``mks`` external crate` when the `system!` macro was invoked in a crate using the 2018 edition. All invocations of the `$quantities!` macro are corrected and a new test crate, `edition_check`, is added to validate `uom` can be used in 2018 edition code. Resolves #119.
- Loading branch information
1 parent
54cc327
commit ddd7039
Showing
13 changed files
with
105 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,5 +85,5 @@ mod f32 { | |
pub use *; | ||
} | ||
|
||
Q!(f32::s, f32); | ||
Q!(crate::f32::s, f32); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "edition_check" | ||
version = "0.1.0" | ||
edition = "2018" | ||
|
||
[dependencies] | ||
# Include `use_serde` to re-use `uom` compiled by `cargo test --verbose --features "use_serde"` | ||
uom = { path = "../..", features = ["use_serde"] } | ||
|
||
[features] | ||
default = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//! Validate that the `system!`, `quantity!`, and `$quantities!` macros generate valid code for the | ||
//! 2018 edition. | ||
#[macro_use] | ||
extern crate uom; | ||
|
||
mod mks { | ||
mod length { | ||
quantity! { | ||
/// Length (base unit meter, m<sup>1</sup>). | ||
quantity: Length; "length"; | ||
/// Length dimension, m<sup>1</sup>. | ||
dimension: Q<P1 /*length*/, Z0 /*mass*/, Z0 /*time*/>; | ||
units { | ||
@meter: 1.0E0; "m", "meter", "meters"; | ||
@foot: 3.048E-1; "ft", "foot", "feet"; | ||
} | ||
} | ||
} | ||
|
||
mod mass { | ||
quantity! { | ||
/// Mass (base unit kilogram, kg<sup>1</sup>). | ||
quantity: Mass; "mass"; | ||
/// Mass dimension, kg<sup>1</sup>. | ||
dimension: Q<Z0 /*length*/, P1 /*mass*/, Z0 /*time*/>; | ||
units { | ||
@kilogram: 1.0; "kg", "kilogram", "kilograms"; | ||
} | ||
} | ||
} | ||
|
||
mod time { | ||
quantity! { | ||
/// Time (base unit second, s<sup>1</sup>). | ||
quantity: Time; "time"; | ||
/// Time dimension, s<sup>1</sup>. | ||
dimension: Q<Z0 /*length*/, Z0 /*mass*/, P1 /*time*/>; | ||
units { | ||
@second: 1.0; "s", "second", "seconds"; | ||
} | ||
} | ||
} | ||
|
||
system! { | ||
/// System of quantities, Q. | ||
quantities: Q { | ||
length: meter, L; | ||
mass: kilogram, M; | ||
time: second, T; | ||
} | ||
/// System of units, U. | ||
units: U { | ||
mod length::Length, | ||
mod mass::Mass, | ||
mod time::Time, | ||
} | ||
} | ||
|
||
mod f32 { | ||
Q!(crate::mks, f32 /*, (centimeter, gram, second)*/); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters