#assert #array #assertions

nearly_eq

Nearly(Approximately) equal traits and assertion

9 releases

Uses old Rust 2015

0.2.4 Mar 28, 2018
0.2.3 Oct 18, 2017
0.1.3 Oct 11, 2017

#1896 in Math

Download history 235/week @ 2024-12-16 144/week @ 2024-12-23 122/week @ 2024-12-30 209/week @ 2025-01-06 161/week @ 2025-01-13 234/week @ 2025-01-20 195/week @ 2025-01-27 277/week @ 2025-02-03 262/week @ 2025-02-10 320/week @ 2025-02-17 241/week @ 2025-02-24 155/week @ 2025-03-03 191/week @ 2025-03-10 189/week @ 2025-03-17 199/week @ 2025-03-24 144/week @ 2025-03-31

744 downloads per month
Used in 17 crates (9 directly)

MPL-2.0 license

21KB
390 lines

rust-nearly-eq

crates.io badge Build Status docs.rs Coverage Status

Implementing the NearlyEq traits, Can asserts that the two expressions are nearly(approximately) equal to each other.

How-to Use

See the crate documentation for more details.

Examples

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

Optional Features

  • complex - Implement NearlyEq traits for num_complex::Complex. This adds a dependency on the num-complex crate.

  • rational - Implement NearlyEq traits for num_rational::Ratio. This adds a dependency on the num-rational crate.

  • ndarray - Implement NearlyEq traits for ndarray::ArrayBase. This adds a dependency on the ndarray crate.

  • use_fpa - Implement NearlyEq traits for fixed-point types of fpa crate.

  • i128 - Implement NearlyEq traits for i128 and u128. Available only on Rust nightly channel.

Dependencies

~0–690KB
~14K SLoC