Macro nearly_eq::debug_assert_nearly_eq0.2.3 [] [src]

macro_rules! debug_assert_nearly_eq {
    ($($arg:tt)*) => { ... };
}

Asserts that two expressions are nearly(approximately) equal to each other.

You can optionally add an optional diff value. If you don't supply a diff value as an argument, NearlyEq::eps() is the default used.

Unlike assert_nearly_eq!, debug_assert_nearly_eq! statements are only enabled in non optimized builds by default. An optimized build will omit all debug_assert_nearly_eq! statements unless -C debug-assertions is passed to the compiler.

Examples

debug_assert_nearly_eq!(1f64, 1.5f64, 0.6f64); // does not panic
debug_assert_nearly_eq!(0f64, 1e-12f64); // does not panic
debug_assert_nearly_eq!(1f64, 2f64); // panics