approx_collections/
lib.rs

1//! Data structures using approximate floating-point comparisons.
2//!
3//! [`Precision`] is the basic struct used by everything in this crate.
4//!
5//! [`FloatPool`] is used for interning floats to reduce accumulated numerical
6//! error and allow direct comparison and hashing via [`ApproxHash`].
7//!
8//! [`ApproxHashMap`] is used for looking up approximate values.
9//!
10//! For implementing approximate comparison on your own types, see [`ApproxEq`],
11//! [`ApproxEqZero`], and [`ApproxOrd`].
12//!
13//! # Example
14//!
15//! ```
16//! # use approx_collections::*;
17//! const APPROX: Precision = Precision::DEFAULT;
18//!
19//! assert_ne!(0.1 + 0.2, 0.3_f64);
20//! assert!(APPROX.eq(0.1 + 0.2, 0.3_f64));
21//! ```
22//!
23//! # Implementation
24//!
25//! See [`Precision`] for details about how floats are compared.
26//!
27//! # Features
28//!
29//! The `rustc-hash` feature is enabled by default, and uses a faster hashing
30//! algorithm for the hash map inside [`FloatPool`].
31
32pub mod hash_map;
33pub mod pool;
34pub mod precision;
35pub mod traits;
36
37pub use hash_map::ApproxHashMap;
38pub use pool::FloatPool;
39pub use precision::Precision;
40pub use traits::*;