1个不稳定版本
0.1.0 | 2023年12月17日 |
---|
#197 在 值格式化
44KB
1.5K SLoC
CashKit
CashKit是一个用于货币兑换和货币信息的Rust库。它允许您执行货币转换并检索有关各种货币的详细信息。
用法
将以下内容添加到您的Cargo.toml
[dependencies]
cashkit = "0.1.0"
货币结构体
#[derive(Debug, Clone, PartialEq)]
pub struct Currency {
pub name: &'static str,
pub code: &'static str,
pub symbol: &'static str,
pub exponent: u8,
pub numeric_code: &'static str,
pub withdrawal_date: &'static str,
pub next_update_date: &'static str,
pub rates: Option<HashMap<String, f32>>,
}
用法示例
use cashkit::{code_currency, exchange};
fn main() {
let from_currency = "USD";
let to_currency = "EUR";
let amount = 100.0;
let result = exchange(from_currency, to_currency, amount);
println!("{} {} is {} {}", amount, from_currency, result, to_currency);
}
货币信息
use cashkit::{code_currency, name_currency, symbol_currency, numeric_code_currency};
fn main() {
let currency_code = "USD";
let currency_name = "US Dollar";
let currency_symbol = "$";
let numeric_code = "840";
let by_code = code_currency(currency_code);
let by_name = name_currency(currency_name);
let by_symbol = symbol_currency(currency_symbol);
let by_numeric_code = numeric_code_currency(numeric_code);
}
货币列表
use cashkit::{active_currencies, withdrawn_currencies};
fn main() {
let active_currencies_list = active_currencies();
let withdrawn_currencies_list = withdrawn_currencies();
... (Handle Vec<Currency> as needed)
}
Rusty Rails项目
Rusty Rails是一个更大的项目,旨在弥合Rust和Ruby/Ruby on Rails之间的差距。我们正在积极努力将ruby库重新创建为rust,以便让新开发者在Rust中工作变得更加容易和有趣。
贡献
欢迎使用对CashKit库的贡献!请随意提交问题、提交拉取请求或提供反馈,以帮助改进此库。