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::{Sub, SubAssign};

use mpdec_sys::{mpd_ssize_t, mpd_uint_t};

impl Decimal {
    gen_decimal_qoperations!(
        checked_sub(Decimal : get_inner) => mpd_qsub;
        checked_sub_i32(i32 : clone) => mpd_qsub_i32;
        checked_sub_i64(i64 : clone) => mpd_qsub_i64;
        checked_sub_ssize(mpd_ssize_t : clone) => mpd_qsub_ssize;
        checked_sub_u32(u32 : clone) => mpd_qsub_u32;
        checked_sub_u64(u64 : clone) => mpd_qsub_u64;
        checked_sub_uint(mpd_uint_t : clone) => mpd_qsub_uint;
    );
}

impl Sub<Decimal> for Decimal {
    type Output = Decimal;
    fn sub(self, rhs: Decimal) -> Self::Output {
        self.checked_sub(&rhs).unwrap()
    }
}
impl SubAssign<Decimal> for Decimal {
    fn sub_assign(&mut self, rhs: Decimal) {
        *self = self.checked_sub(&rhs).unwrap();
    }
}

impl Sub<i32> for Decimal {
    type Output = Decimal;
    fn sub(self, rhs: i32) -> Self::Output {
        self.checked_sub_i32(&rhs).unwrap()
    }
}
impl SubAssign<i32> for Decimal {
    fn sub_assign(&mut self, rhs: i32) {
        *self = self.checked_sub_i32(&rhs).unwrap()
    }
}

impl Sub<i64> for Decimal {
    type Output = Decimal;
    fn sub(self, rhs: i64) -> Self::Output {
        self.checked_sub_i64(&rhs).unwrap()
    }
}
impl SubAssign<i64> for Decimal {
    fn sub_assign(&mut self, rhs: i64) {
        *self = self.checked_sub_i64(&rhs).unwrap()
    }
}

impl Sub<u32> for Decimal {
    type Output = Decimal;
    fn sub(self, rhs: u32) -> Self::Output {
        self.checked_sub_u32(&rhs).unwrap()
    }
}
impl SubAssign<u32> for Decimal {
    fn sub_assign(&mut self, rhs: u32) {
        *self = self.checked_sub_u32(&rhs).unwrap()
    }
}

impl Sub<u64> for Decimal {
    type Output = Decimal;
    fn sub(self, rhs: u64) -> Self::Output {
        self.checked_sub_u64(&rhs).unwrap()
    }
}
impl SubAssign<u64> for Decimal {
    fn sub_assign(&mut self, rhs: u64) {
        *self = self.checked_sub_u64(&rhs).unwrap();
    }
}