You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The unit_system macro generates the type aliases corresponding to the dimensions and the Quantity constructors corresponding to the units for every storage type. It can happen quite quickly that one defines a dimension/unit that is only used for one of the storage types. In that case, a confusing unused code warning will be emitted if the module which calls unit_system is not a public export of the current crate. Minimal example:
use diman::unit_system;
unit_system!(
quantity_type Quantity;
dimension_type Dimension;
dimension Length;
#[base(Length)]
unit meter: Length;
);
pub fn main() {
let x = self::f32::Length::meter(5.0);
}
With f32 and f64 features enabled, this will generate an error
warning: type alias `Length` is never used
--> src/my_mod.rs:7:15
|
7 | dimension Length;
| ^^^^^^
I only see two simple solutions to this problem:
Add #[allow(unused)] for every dimension / unit constructor.
Require users to export the Quantity struct by making the module which calls unit_system a public part of the library.
Now 2. is how it currently is, but is clearly not a good solution. Implementing 1. is fine in principle, but it is a bit unfortunate that this rules out getting useful warnings that could identify unused dimensions/units.
The text was updated successfully, but these errors were encountered:
The
unit_system
macro generates the type aliases corresponding to the dimensions and theQuantity
constructors corresponding to the units for every storage type. It can happen quite quickly that one defines a dimension/unit that is only used for one of the storage types. In that case, a confusing unused code warning will be emitted if the module which callsunit_system
is not a public export of the current crate. Minimal example:With
f32
andf64
features enabled, this will generate an errorI only see two simple solutions to this problem:
#[allow(unused)]
for every dimension / unit constructor.unit_system
a public part of the library.Now 2. is how it currently is, but is clearly not a good solution. Implementing 1. is fine in principle, but it is a bit unfortunate that this rules out getting useful warnings that could identify unused dimensions/units.
The text was updated successfully, but these errors were encountered: