money/money
This module provides types and methods for safe monetary calculations
Types
Represents the error when trying to add two currencies that don’t match
pub type MoneyError {
CurrencyMismatch(
expected_currency: String,
received_currency: String,
)
}
Constructors
-
CurrencyMismatch( expected_currency: String, received_currency: String, )Currencies that failed to match
Values
pub fn add(
from: Money,
other: Money,
) -> Result(Money, MoneyError)
Safely add two amounts of money and produce the new amount or, an error otherwise