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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//! # Licensing
//! This Source Code is subject to the terms of the Mozilla Public License
//! version 2.0 (the "License"). You can obtain a copy of the License at
//! [http://mozilla.org/MPL/2.0/](http://mozilla.org/MPL/2.0/).
/// Asserts that two expressions are nearly(approximately) equal to each other.
///
/// You can optionally add an optional diff value. If you don't supply
/// a diff value as an argument, NearlyEq::eps() is the default used.
///
/// # Examples
///
/// ```rust
/// # #[macro_use] extern crate nearly_eq;
/// # fn main() {
/// assert_nearly_eq!(1f64, 1.5f64, 0.6f64); // does not panic
/// assert_nearly_eq!(0f64, 1e-12f64); // does not panic
/// # }
/// ```
/// ```should_panic
/// # #[macro_use] extern crate nearly_eq;
/// # fn main() {
/// assert_nearly_eq!(1f64, 2f64); // panics
/// # }
/// ```
/// Asserts that two expressions are nearly(approximately) equal to each other.
///
/// You can optionally add an optional diff value. If you don't supply
/// a diff value as an argument, NearlyEq::eps() is the default used.
///
/// Unlike assert_nearly_eq!, debug_assert_nearly_eq! statements are only enabled in non optimized builds by default.
/// An optimized build will omit all debug_assert_nearly_eq! statements unless -C debug-assertions is passed to the compiler.
///
/// # Examples
///
/// ```rust
/// # #[macro_use] extern crate nearly_eq;
/// # fn main() {
/// debug_assert_nearly_eq!(1f64, 1.5f64, 0.6f64); // does not panic
/// debug_assert_nearly_eq!(0f64, 1e-12f64); // does not panic
/// # }
/// ```
/// ```should_panic
/// # #[macro_use] extern crate nearly_eq;
/// # fn main() {
/// debug_assert_nearly_eq!(1f64, 2f64); // panics
/// # }
/// ```