diff --git a/crates/cross/src/real.rs b/crates/cross/src/real.rs index 62ad7e0..224cc57 100644 --- a/crates/cross/src/real.rs +++ b/crates/cross/src/real.rs @@ -18,6 +18,12 @@ pub trait ToFloat { fn to_f64(&self) -> f64 { self.to_f32() as _ } + fn to_r32(&self) -> R32 { + R32::new(self.to_f32()) + } + fn to_r64(&self) -> R64 { + R64::new(self.to_f64()) + } } @@ -383,6 +389,16 @@ impl Div for Finite { } } +#[cfg(feature = "iter")] +impl std::iter::Sum for Finite { + fn sum(iter: I) -> Self + where + I: Iterator + { + iter.fold(Self::zero(), |a, b| a + b) + } +} + impl ToFloat for Finite { fn to_f32(&self) -> f32 {