Add Amount::convert_unit convenience method

This commit is contained in:
David Caseria
2025-06-27 15:28:39 -04:00
parent dd81b9a947
commit 8d32af740e

View File

@@ -172,6 +172,15 @@ impl Amount {
acc.checked_add(x).ok_or(Error::AmountOverflow)
})
}
/// Convert unit
pub fn convert_unit(
&self,
current_unit: &CurrencyUnit,
target_unit: &CurrencyUnit,
) -> Result<Amount, Error> {
to_unit(self.0, current_unit, target_unit)
}
}
impl Default for Amount {