Proc_macro derivation of Unit
for the
unit_system
crate.
It derives Unit
for a struct B and declares structs which also derive
Unit
and whose BaseUnit
is the initial struct B. They form a typical SI
unit system. Roughly,
```rust
struct B(f64); ```
results into
``rust
// The base unit is its own
BaseUnit`
impl Unit for B {
type BaseUnit = Self;
fn tobase(self) -> Self {
self
}
fn frombase(base: B) -> Self {
base
}
}
struct NB(f64);
struct MuB(f64);
struct MB(f64);
struct CB(f64);
struct DeciB(f64);
struct HB(f64);
struct KB(f64);
/// kiloB is 1000 B impl Unit for KB { type BaseUnit = B; fn tobase(self) -> B { B(self * 1000.) } fn frombase(base: Self::BaseUnit) -> Self { Self(base / 1000.) } }
// ...the same for the rest of units ```