use super::{CubicCentimetre, Litre, Unit}; #[derive(Debug, Default, PartialEq)] pub struct CubicMetre(pub f64); impl CubicMetre { pub fn from_unit>(unit: Unit, value: F) -> Self { match unit { Unit::CubicMetre => Self(value.into()), Unit::Litre => Self::from(Litre(value.into())), Unit::CubicCentimetre => Self::from(CubicCentimetre(value.into())), } } } impl From for CubicMetre { fn from(value: Litre) -> Self { Self(value.0 * 10_f64.powi(-3)) } } impl From for CubicMetre { fn from(value: CubicCentimetre) -> Self { Self(value.0 * 10_f64.powi(-6)) } }