pub fn add(&mut self, key: &Address, value: &TokenAmount) -> Result<(), Box<dyn StdError>> {
        let prev = self.get(&key)?;
        let sum = &prev + value;
        if sum.is_negative() {
            Err(format!("New balance in table cannot be negative: {}", sum).into())
        } else if sum.is_zero() && !prev.is_zero() {
            self.0.delete(&key.to_bytes())?;
            Ok(())
        } else {
            Ok(self.0.set(key.to_bytes().into(), BigIntDe(sum))?)
        }
    }
/// Adds token amount to previously initialized account.
Adds token amount to previously initialized account.
Adds token amount to previously initialized account .
pub fn add(&mut self, key: &Address, value: &TokenAmount) -> Result<(), Box<dyn StdError>> {
        let prev = self.get(&key)?;
        let sum = &prev + value;
        if sum.is_negative() {
            Err(format!("New balance in table cannot be negative: {}", sum).into())
        } else if sum.is_zero() && !prev.is_zero() {
            self.0.delete(&key.to_bytes())?;
            Ok(())
        } else {
            Ok(self.0.set(key.to_bytes().into(), BigIntDe(sum))?)
        }
    }
pub fn add ( & mut self , key : & Address , value : & TokenAmount ) -> Result < ( ) , Box < dyn StdError > > { let prev = self . get ( & key ) ? ; let sum = & prev + value ; if sum . is_negative ( ) { Err ( format ! ( " " sum ) . into ( ) ) } else if sum . is_zero ( ) && ! prev . is_zero ( ) { self . 0 . delete ( & key . to_bytes ( ) ) ? ; Ok ( ( ) ) } else { Ok ( self . 0 . set ( key . to_bytes ( ) . into ( ) , BigIntDe ( sum ) ) ? ) } }
Adds token amount to previously initialized account.
Adds token amount to previously initialized account .
&mut self
key
&Address
value
&TokenAmount