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::math_rational_rational::{rational_from_value, rational_from_wide, rational_parts, rational_to_value}; ← rational, another function of this group · built into the same file, even by a slim install
/// a ÷ b, reduced. Dividing by zero is an error, never an infinity.
///
/// # Panics
/// Panics if `b` is zero, on a zero denominator, or a result outside ±(2^53 - 1).
pub fn divide_rational(a: &Rational, b: &Rational) -> Rational {
let (an, ad) = rational_parts(a);
let (bn, bd) = rational_parts(b);
if bn == 0 {
panic!("division by zero");
}
rational_from_wide(an * bd, ad * bn)
}
pub fn fune_vector(args: &[Value]) -> Value {
rational_to_value(÷_rational(&rational_from_value(&args[0]), &rational_from_value(&args[1])))
}