Trait MaxDifference

Source
pub trait MaxDifference {
    // Required method
    fn max_diff(self, other: Self) -> f64;
}
Expand description

Helper trait for assert_about_equal macro. Returns the max difference between two vectors of floats. Can also be used for single floats.

§Examples

Compare two floating numbers:

assert!((0.1f64 - 42.1f32.max_diff(42.0f32)) < 1.0e-4f64);

Compare two vectors. Returns the maximum difference in the vectors. In this case ~0.1.:

assert!(0.1f64 - vec![42.0, 42.0f32, 1.001f32].max_diff(vec![42.0, 42.1f32, 1.0f32]) < 1.0e-4f64);

Compare two arrays. Trait implemented for arrays of length 0-32:

assert!(0.1f64 - [42.0, 42.0f32, 1.001f32].max_diff([42.0, 42.1f32, 1.0f32]) < 1.0e-4f64);

Required Methods§

Source

fn max_diff(self, other: Self) -> f64

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl MaxDifference for f32

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for f64

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for Vec<f32>

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for Vec<f64>

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 0]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 1]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 2]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 3]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 4]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 5]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 6]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 7]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 8]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 9]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 10]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 11]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 12]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 13]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 14]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 15]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 16]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 17]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 18]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 19]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 20]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 21]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 22]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 23]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 24]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 25]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 26]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 27]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 28]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 29]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 30]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 31]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f32; 32]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 0]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 1]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 2]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 3]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 4]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 5]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 6]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 7]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 8]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 9]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 10]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 11]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 12]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 13]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 14]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 15]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 16]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 17]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 18]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 19]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 20]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 21]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 22]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 23]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 24]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 25]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 26]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 27]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 28]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 29]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 30]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 31]

Source§

fn max_diff(self, other: Self) -> f64

Source§

impl MaxDifference for [f64; 32]

Source§

fn max_diff(self, other: Self) -> f64

Implementors§