mpdec 4.0.1

wrapper for libmpdec math library
Documentation
pub mod add;
pub mod div;
pub mod mul;
pub mod rem;
pub mod sub;

macro_rules! gen_decimal_qoperations {
    (
        $($func_name:ident($type:ty $(: $func:ident)?) => $mpd_qfunc:ident;)*
    ) => {
        $(
            pub fn $func_name(&self, other: &$type) -> Result<Decimal, MPDecimalError> {
                let result = Decimal::checked_new()?;

                let mut status: u32 = 0;

                unsafe {
                    mpdec_sys::$mpd_qfunc(
                        result.inner,
                        self.inner,
                        other$(.$func())?,
                        &mut *get_context(),
                        &mut status,
                    );
                }

                MPDecimalError::from_status(status)?;

                Ok(result)
            }
        )*
    };
}

pub(crate) use gen_decimal_qoperations;