dashu-ratio 0.6.0

Arbitrary-precision rational math library for Rust. Provides RBig and a relaxed variant for fast computation, with small values inlined on the stack. Exact arithmetic, Diophantine approximation of floats, parsing and formatting in any base including repeating-decimal notation, and conversions to and from other dashu types. Optional serde, rand, num-traits, rkyv, and zeroize.
Documentation
//! Implementation of core::iter traits

use crate::rbig::{RBig, Relaxed};
use core::{
    iter::{Product, Sum},
    ops::{Add, Mul},
};

macro_rules! impl_fold_iter {
    ($t:ty, $fold_trait:ident, $fold:ident, $op_trait:ident, $op:ident, $init:ident) => {
        impl<T> $fold_trait<T> for $t
        where
            $t: $op_trait<T, Output = $t>,
        {
            fn $fold<I: Iterator<Item = T>>(iter: I) -> Self {
                iter.fold(<$t>::$init, <$t>::$op)
            }
        }
    };
}

impl_fold_iter!(RBig, Sum, sum, Add, add, ZERO);
impl_fold_iter!(Relaxed, Sum, sum, Add, add, ZERO);
impl_fold_iter!(RBig, Product, product, Mul, mul, ONE);
impl_fold_iter!(Relaxed, Product, product, Mul, mul, ONE);