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