conformal_component::audio

Function all_approx_eq

Source
pub fn all_approx_eq<L: IntoIterator<Item = f32>, R: IntoIterator<Item = f32>>(
    lhs: L,
    rhs: R,
    e: f32,
) -> bool
Expand description

Checks if all the values from two iterators of f32 values are within e of each other.

This is useful for comparing ranges of floating point values, while allowing for some rounding errors.

ยงExamples

assert!(all_approx_eq([1.0, 2.0, 3.0], [1.01, 2.01, 3.01], 0.1));
assert!(!all_approx_eq([1.0, 2.0, 3.0], [1.01, 2.2, 3.01], 0.1));
assert!(!all_approx_eq([1.0, 2.0, 3.0], [1.0, 2.0], 0.1));