-
Notifications
You must be signed in to change notification settings - Fork 127
Open
Description
I mentioned in this issue: #357 (comment) my need for a LinearEnergyDensity type. My use case would include a wh/mi representation and such. Can anyone guide me through how to create such a unit? I'm a bit lost. Thanks!
I created this as a stop-gap:
pub struct LinearEnergyDensity<T: uom::si::length::Conversion<f32>> {
energy: Energy,
_base_unit: T,
}
impl<T: uom::si::length::Conversion<f32>> LinearEnergyDensity<T> {
pub const fn new(energy: Energy, base_unit: T) -> Self {
Self {
energy,
_base_unit: base_unit,
}
}
}
impl<T: uom::si::length::Conversion<f32>> Mul<Length> for LinearEnergyDensity<T> {
type Output = Energy;
fn mul(self, rhs: Length) -> Self::Output {
let conv_length = rhs.get::<T>();
self.energy * conv_length
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels