#assert #array

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

#2933 in Rust patterns

Download history 220/week @ 2025-07-27 204/week @ 2025-08-03 207/week @ 2025-08-10 187/week @ 2025-08-17 254/week @ 2025-08-24 374/week @ 2025-08-31 311/week @ 2025-09-07 392/week @ 2025-09-14 315/week @ 2025-09-21 463/week @ 2025-09-28 225/week @ 2025-10-05 255/week @ 2025-10-12 273/week @ 2025-10-19 347/week @ 2025-10-26 421/week @ 2025-11-02 277/week @ 2025-11-09

1,406 downloads per month
Used in 15 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–730KB
~15K SLoC