From 147907c8677efbd30585fcf79986e9d079db1514 Mon Sep 17 00:00:00 2001 From: Mike Boutin Date: Fri, 1 Apr 2022 14:22:35 -0400 Subject: [PATCH] Make `Units` trait type alias created by `$quantities!` macro `pub`. Part of #295 where the need to access the `Units` trait for a user-defined system of units was uncovered. --- src/system.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/system.rs b/src/system.rs index f8f4e37c..a9fb3b70 100644 --- a/src/system.rs +++ b/src/system.rs @@ -1546,10 +1546,11 @@ macro_rules! system { /// * `$system`: Path to the module where the [`system!`](macro.system.html) macro was run /// (e.g. `uom::si`). /// * `$V`: Underlying value storage type (e.g. `f32`). - /// * `$U`: Optional. Base units. Pass as a tuple with the desired units: `(meter, kilogram, - /// second, ampere, kelvin, mole, candela)`. The system's base units will be used if no - /// value is provided. Note that a unit with a non-zero constant factor is not currently - /// supported as a base unit. + /// * `$U`: Optional. Base units. Pass as a tuple with the desired units: (e.g. `(meter, + /// kilogram, second, ampere, kelvin, mole, candela)`). The system's base units will be + /// used if no value is provided. When a value is provided a new trait type alias, + /// `Units`, is defined. Note that a unit with a non-zero constant factor is not + /// currently supported as a base unit. /// /// An example invocation is given below for a meter-kilogram-second system setup in the /// module `mks` with a system of quantities name `Q`. The `#[macro_use]` attribute must be @@ -1656,7 +1657,13 @@ macro_rules! system { ) => { use $path as __system; - type Units = dyn __system::Units<$V, $($name = __system::$name::$U,)+>; + /// `Units` trait type alias to identify a [system of units][units] based on the set of + /// given [base units][base] of a [system of quantities][quantities]. + /// + /// [units]: https://jcgm.bipm.org/vim/en/1.13.html + /// [base]: https://jcgm.bipm.org/vim/en/1.10.html + /// [quantities]: https://jcgm.bipm.org/vim/en/1.3.html + pub type Units = dyn __system::Units<$V, $($name = __system::$name::$U,)+>; $(/// [`Quantity`](struct.Quantity.html) type alias using the given base units. #[allow(dead_code)]