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//! [`FloatInterner`] is used for canonicalizing floats to reduce accumulated
6//! numerical error and allow direct comparison using [`PartialEq`].
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 [`FloatInterner`].
31
32pub mod hash;
33pub mod hash_map;
34pub mod intern;
35pub mod precision;
36pub mod traits;
37
38pub use hash_map::ApproxHashMap;
39pub use intern::FloatInterner;
40pub use precision::Precision;
41pub use traits::*;