pub struct Balance {
pub balance: HashMap<Option<Rc<Currency>>, Money>,
}Expand description
Balance is money with several currencies, for example 100 USD and 50 EUR
Fields§
§balance: HashMap<Option<Rc<Currency>>, Money>Implementations§
Source§impl Balance
impl Balance
pub fn new() -> Balance
Sourcepub fn to_money(&self) -> Result<Money, BalanceError>
pub fn to_money(&self) -> Result<Money, BalanceError>
Automatic conversion from balance to regular money it can only be done if the balance has only one currency
pub fn is_zero(&self) -> bool
Sourcepub fn can_be_zero(&self) -> bool
pub fn can_be_zero(&self) -> bool
Whether a balance can be zero To be true, there must be positive and negative amounts
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> Iter<'_, Option<Rc<Currency>>, Money>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Balance
impl !Send for Balance
impl !Sync for Balance
impl !UnwindSafe for Balance
impl Freeze for Balance
impl Unpin for Balance
impl UnsafeUnpin for Balance
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more