rl_lang/docs/entries/stdlib/debug/
assert_approx_eq.rs1use crate::docs::entry::FnEntry;
2
3pub static ASSERT_APPROX_EQ: FnEntry = FnEntry {
4 signature: "assert_approx_eq(a, b, epsilon?)",
5 description: "errors if `a` and `b` differ by more than `epsilon` (default 1e-9); use for float comparisons instead of assert_eq, since exact float equality is unreliable",
6 example: r#"
7get std::debug::assert_approx_eq
8
9assert_approx_eq(0.1 + 0.2, 0.3)
10assert_approx_eq(1.0, 1.1, 0.2)"#,
11 expected_output: None,
12 returns: "null",
13 errors: Some(
14 "raises a runtime error when the absolute difference exceeds `epsilon`, or when the arguments aren't numeric",
15 ),
16 see_also: &["assert_eq"],
17 since: Some("v0.1.5"),
18};