Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
use super::funejson::Value; ← the fune runtime: the JSON value the test vectors use; fune build keeps it only where a signature takes one
use super::money_amount::{assert_same_currency, money_from_value, Money}; ← from money.amount ^1.0.0 · built alongside by fune
/// -1, 0 or 1, comparing two amounts of the same currency.
///
/// Refuses mixed currencies: which of GBP 10 and EUR 10 is larger depends on a
/// rate, and a comparison that ignores the currency sorts a list into nonsense.
///
/// # Panics
/// Panics if the two amounts are in different currencies.
pub fn compare_money(a: &Money, b: &Money) -> i64 {
assert_same_currency(a, b);
match a.minor.cmp(&b.minor) {
std::cmp::Ordering::Less => -1,
std::cmp::Ordering::Equal => 0,
std::cmp::Ordering::Greater => 1,
}
}
pub fn fune_vector(args: &[Value]) -> Value {
Value::Int(compare_money(
&money_from_value(&args[0]),
&money_from_value(&args[1]),
))
}