katjing 0.1.0

A money library exploring the aplicability of Rusts unique language features for safe money management.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub trait Currency: std::fmt::Debug {
    const ALPHABETIC_CODE: ::iso_currency::Currency;
    fn minor_unit() -> u16 {
        Self::ALPHABETIC_CODE.subunit_fraction().unwrap_or_else(||1)
    }
}

#[macro_export]
macro_rules! create_currency {
    ($name:ident, $minor_unit_decimals:expr) => (
        #[derive(Debug, PartialEq, PartialOrd)]
        pub struct $name();
        impl $crate::Currency for $name {
            const ALPHABETIC_CODE: ::iso_currency::Currency = ::iso_currency::Currency::$name;
        }
    )
}