Skip to content

Commit 147907c

Browse files
committed
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.
1 parent 49fc627 commit 147907c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/system.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,10 +1546,11 @@ macro_rules! system {
15461546
/// * `$system`: Path to the module where the [`system!`](macro.system.html) macro was run
15471547
/// (e.g. `uom::si`).
15481548
/// * `$V`: Underlying value storage type (e.g. `f32`).
1549-
/// * `$U`: Optional. Base units. Pass as a tuple with the desired units: `(meter, kilogram,
1550-
/// second, ampere, kelvin, mole, candela)`. The system's base units will be used if no
1551-
/// value is provided. Note that a unit with a non-zero constant factor is not currently
1552-
/// supported as a base unit.
1549+
/// * `$U`: Optional. Base units. Pass as a tuple with the desired units: (e.g. `(meter,
1550+
/// kilogram, second, ampere, kelvin, mole, candela)`). The system's base units will be
1551+
/// used if no value is provided. When a value is provided a new trait type alias,
1552+
/// `Units`, is defined. Note that a unit with a non-zero constant factor is not
1553+
/// currently supported as a base unit.
15531554
///
15541555
/// An example invocation is given below for a meter-kilogram-second system setup in the
15551556
/// module `mks` with a system of quantities name `Q`. The `#[macro_use]` attribute must be
@@ -1656,7 +1657,13 @@ macro_rules! system {
16561657
) => {
16571658
use $path as __system;
16581659

1659-
type Units = dyn __system::Units<$V, $($name = __system::$name::$U,)+>;
1660+
/// `Units` trait type alias to identify a [system of units][units] based on the set of
1661+
/// given [base units][base] of a [system of quantities][quantities].
1662+
///
1663+
/// [units]: https://jcgm.bipm.org/vim/en/1.13.html
1664+
/// [base]: https://jcgm.bipm.org/vim/en/1.10.html
1665+
/// [quantities]: https://jcgm.bipm.org/vim/en/1.3.html
1666+
pub type Units = dyn __system::Units<$V, $($name = __system::$name::$U,)+>;
16601667

16611668
$(/// [`Quantity`](struct.Quantity.html) type alias using the given base units.
16621669
#[allow(dead_code)]

0 commit comments

Comments
 (0)