feat: is_dividable compilation error and print unsupported quantity type
This commit is contained in:
parent
d4acccde9d
commit
dfc080f26a
1 changed files with 10 additions and 1 deletions
|
@ -46,7 +46,7 @@ impl FromStr for QuantityUnit {
|
||||||
MILLI_LITER => Ok(Self::MilliLiter),
|
MILLI_LITER => Ok(Self::MilliLiter),
|
||||||
LITER => Ok(Self::Liter),
|
LITER => Ok(Self::Liter),
|
||||||
MILLI_GRAM => Ok(Self::Milligram),
|
MILLI_GRAM => Ok(Self::Milligram),
|
||||||
_ => Err("Currency unsupported".into()),
|
_ => Err(format!("Quantity unsupported: {s}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,15 @@ impl QuantityPart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_dividable(&self) -> bool {
|
||||||
|
match self.unit {
|
||||||
|
QuantityUnit::Kilogram | QuantityUnit::Liter | QuantityUnit::Gram => true,
|
||||||
|
QuantityUnit::Milligram | QuantityUnit::MilliLiter | QuantityUnit::DiscreteNumber => {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
Loading…
Reference in a new issue