mpdec 4.0.1

wrapper for libmpdec math library
Documentation
use super::gen_decimal_qoperations;

use crate::{Decimal, context::get_context, error::MPDecimalError};

use std::ops::{Add, AddAssign};

use mpdec_sys::{mpd_ssize_t, mpd_uint_t};

impl Decimal {
    gen_decimal_qoperations!(
        checked_add(Decimal : get_inner) => mpd_qadd;
        checked_add_i32(i32 : clone) => mpd_qadd_i32;
        checked_add_i64(i64 : clone) => mpd_qadd_i64;
        checked_add_ssize(mpd_ssize_t : clone) => mpd_qadd_ssize;
        checked_add_u32(u32 : clone) => mpd_qadd_u32;
        checked_add_u64(u64 : clone) => mpd_qadd_u64;
        checked_add_uint(mpd_uint_t : clone) => mpd_qadd_uint;
    );
}

impl Add<Decimal> for Decimal {
    type Output = Decimal;
    fn add(self, rhs: Decimal) -> Self::Output {
        self.checked_add(&rhs).unwrap()
    }
}
impl AddAssign<Decimal> for Decimal {
    fn add_assign(&mut self, rhs: Decimal) {
        *self = self.checked_add(&rhs).unwrap();
    }
}

impl Add<i32> for Decimal {
    type Output = Decimal;
    fn add(self, rhs: i32) -> Self::Output {
        self.checked_add_i32(&rhs).unwrap()
    }
}
impl AddAssign<i32> for Decimal {
    fn add_assign(&mut self, rhs: i32) {
        *self = self.checked_add_i32(&rhs).unwrap()
    }
}

impl Add<i64> for Decimal {
    type Output = Decimal;
    fn add(self, rhs: i64) -> Self::Output {
        self.checked_add_i64(&rhs).unwrap()
    }
}
impl AddAssign<i64> for Decimal {
    fn add_assign(&mut self, rhs: i64) {
        *self = self.checked_add_i64(&rhs).unwrap()
    }
}

impl Add<u32> for Decimal {
    type Output = Decimal;
    fn add(self, rhs: u32) -> Self::Output {
        self.checked_add_u32(&rhs).unwrap()
    }
}
impl AddAssign<u32> for Decimal {
    fn add_assign(&mut self, rhs: u32) {
        *self = self.checked_add_u32(&rhs).unwrap()
    }
}

impl Add<u64> for Decimal {
    type Output = Decimal;
    fn add(self, rhs: u64) -> Self::Output {
        self.checked_add_u64(&rhs).unwrap()
    }
}
impl AddAssign<u64> for Decimal {
    fn add_assign(&mut self, rhs: u64) {
        *self = self.checked_add_u64(&rhs).unwrap();
    }
}