pub fn debit(
        &mut self,
        from: &AccountIdentifier,
        amount: Tokens,
    ) -> Result<Tokens, BalanceError> {
        self.store.update(*from, |prev| {
            let mut balance = match prev {
                Some(x) => *x,
                None => {
                    return Err(BalanceError::InsufficientFunds {
                        balance: Tokens::ZERO,
                    });
                }
            };
            if balance < amount {
                return Err(BalanceError::InsufficientFunds { balance });
            }

            balance -= amount;
            Ok(balance)
        })
    }
// Debiting an account will automatically remove it from the `inner`
// HashMap if the balance reaches zero.
Debiting an account will automatically remove it from the `inner`
HashMap if the balance reaches zero.
Debiting an account will automatically remove it from the ` inner ` HashMap if the balance reaches zero .
pub fn debit(
        &mut self,
        from: &AccountIdentifier,
        amount: Tokens,
    ) -> Result<Tokens, BalanceError> {
        self.store.update(*from, |prev| {
            let mut balance = match prev {
                Some(x) => *x,
                None => {
                    return Err(BalanceError::InsufficientFunds {
                        balance: Tokens::ZERO,
                    });
                }
            };
            if balance < amount {
                return Err(BalanceError::InsufficientFunds { balance });
            }
            balance -= amount;
            Ok(balance)
        })
    }
pub fn debit ( & mut self , from : & AccountIdentifier , amount : Tokens , ) -> Result < Tokens , BalanceError > { self . store . update ( * from , | prev | { let mut balance = match prev { Some ( x ) => * x , None => { return Err ( BalanceError :: InsufficientFunds { balance : Tokens :: ZERO , } ) ; } } ; if balance < amount { return Err ( BalanceError :: InsufficientFunds { balance } ) ; } balance -= amount ; Ok ( balance ) } ) }
Debiting an account will automatically remove it from the `inner`
HashMap if the balance reaches zero.
Debiting an account will automatically remove it from the ` inner ` HashMap if the balance reaches zero .
&mut self
from
&AccountIdentifier
amount
Tokens
&mut self
from
&AccountIdentifier
amount
Tokens