/// Subtract a value from an account state, and return the new state.
///
/// Note that this *also* increment the counter, as this function would be usually call
/// for spending.
///
/// If the counter is also reaching the extremely rare of max, we only authorise
/// a total withdrawal of fund otherwise the fund will be stuck forever in limbo.
Subtract a value from an account state, and return the new state.
Note that this *also* increment the counter, as this function would be usually call
for spending.

If the counter is also reaching the extremely rare of max, we only authorise
a total withdrawal of fund otherwise the fund will be stuck forever in limbo.
Subtract a value from an account state and return the new state . Note that this * also * increment the counter as this function would be usually call for spending . If the counter is also reaching the extremely rare of max we only authorise a total withdrawal of fund otherwise the fund will be stuck forever in limbo .
pub fn sub(&self, v: Value) -> Result<Option<Self>, LedgerError> {
        let new_value = (self.value - v)?;
        match self.counter.increment() {
            None => {
                if new_value == Value::zero() {
                    Ok(None)
                } else {
                    Err(LedgerError::NeedTotalWithdrawal)
                }
            }
            Some(new_counter) => Ok(Some(Self {
                counter: new_counter,
                value: new_value,
            })),
        }
    }
pub fn sub ( & self , v : Value ) -> Result < Option < Self > , LedgerError > { let new_value = ( self . value - v ) ? ; match self . counter . increment ( ) { None => { if new_value == Value :: zero ( ) { Ok ( None ) } else { Err ( LedgerError :: NeedTotalWithdrawal ) } } Some ( new_counter ) => Ok ( Some ( Self { counter : new_counter , value : new_value , } ) ) , } }
Subtract a value from an account state, and return the new state.
Subtract a value from an account state and return the new state .
&self
v
Value