unitx-core 0.1.0

Fast unit conversion primitives with live currency rates.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use rust_decimal::Decimal;
use std::error::Error;
use std::str::FromStr;
use unitx_core::currency::{convert, CurrencyUnit};

fn main() -> Result<(), Box<dyn Error>> {
    let amount = Decimal::from_str("100.00")?;
    let converted = convert(amount, CurrencyUnit::USD, CurrencyUnit::EUR)?;

    println!("USD {} -> EUR {}", amount, converted);
    Ok(())
}