pub trait NumericAddable: ToBigDecimal {
// Required methods
fn add_assign_to(&self, target: &mut BigDecimal);
fn sub_assign_from(&self, target: &mut BigDecimal);
}Expand description
Trait for types that can be added to a BigDecimal in-place
This trait enables efficient accumulation by mutating a BigDecimal directly
instead of creating intermediate allocations. Types implementing this trait
can be used with the add() and sub() methods on database rows.
This trait extends ToBigDecimal to allow conversion to BigDecimal when needed.
Required Methods§
Sourcefn add_assign_to(&self, target: &mut BigDecimal)
fn add_assign_to(&self, target: &mut BigDecimal)
Add self to the target BigDecimal, mutating it directly
This enables efficient accumulation without intermediate allocations.
For example: 100i64.add_assign_to(&mut target) will add 100 to target.
Sourcefn sub_assign_from(&self, target: &mut BigDecimal)
fn sub_assign_from(&self, target: &mut BigDecimal)
Subtract self from the target BigDecimal, mutating it directly
Equivalent to: *target -= self
For example: 50i64.sub_assign_from(&mut target) will subtract 50 from target.