#![allow(missing_docs)]
use core::ops::{Div, Mul};
use crate::{
dimension::{CanDimPowType, Exponent, HasTypenum},
units::{compound::*, traits::*},
};
struct _Notes;
macro_rules! concrete_mod {
($(#[$attr:meta])+ $vis:vis use $module:ident::$unit:ident;) => {
$(#[$attr])+
mod $module;
$vis use $module::$unit;
};
($vis:vis use $module:ident::$unit:ident;) => {
#[doc = concat!(
"Module for the ",
"[`", stringify!($unit), "`]",
"(", stringify!($module), "::", stringify!($unit), ")",
" concrete unit type.",
)]
mod $module;
$vis use $module::$unit;
};
}
macro_rules! concrete_types {
($(
$(#[$attr:meta])*
$module:ident::$unit:ident
),+$(,)?) => {
$(concrete_mod! {
$(#[$attr])*
pub use $module::$unit;
})+
$(
impl Default for $unit {
fn default() -> Self { Self::BASE }
}
impl ::core::fmt::Display for $unit {
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
<str as core::fmt::Display>::fmt(self.symbol(), f)
}
}
impl<U: Unit> Div<U> for $unit where Self: CanUnitDiv<U> {
type Output = UnitDiv<Self, U>;
fn div(self, rhs: U) -> Self::Output {
UnitDiv::new(self, rhs)
}
}
impl<U: Unit> Mul<U> for $unit where Self: CanUnitMul<U> {
type Output = UnitMul<Self, U>;
fn mul(self, rhs: U) -> Self::Output {
UnitMul::new(self, rhs)
}
}
impl ::num_traits::Inv for $unit where Self: CanUnitInv {
type Output = PerUnit<Self>;
fn inv(self) -> Self::Output {
PerUnit::new(self)
}
}
impl<const E: i32> CanPow<E> for $unit where
Exponent<E>: HasTypenum,
Self::Dim: CanDimPowType<<Exponent<E> as HasTypenum>::Typenum>,
{
type Output = UnitPow<Self, <Exponent<E> as HasTypenum>::Typenum>;
fn pow(self) -> Self::Output {
UnitPow::new(self)
}
}
)+
};
}
concrete_types!(
one::One,
length::Length,
mass::Mass,
time::Time,
frequency::Frequency,
temp::Temp,
amount::Amount,
intensity::Intensity,
force::Force,
volume::Volume,
pressure::Pressure,
energy::Energy,
power::Power,
charge::Charge,
current::Current,
voltage::Voltage,
resistance::Resistance,
);