Skip to main content

NumericAddable

Trait NumericAddable 

Source
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§

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl NumericAddable for &str

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for &BigDecimal

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for &BigInt

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for i8

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for i16

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for i32

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for i64

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for i128

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for isize

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for u8

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for u16

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for u32

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for u64

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for u128

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for usize

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for String

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for BigDecimal

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Source§

impl NumericAddable for BigInt

Source§

fn add_assign_to(&self, target: &mut BigDecimal)

Source§

fn sub_assign_from(&self, target: &mut BigDecimal)

Implementors§