From a04dbb0ab9fd79cba5faaa2cf8e03082b2831387 Mon Sep 17 00:00:00 2001 From: Sander Saares Date: Tue, 9 Jul 2024 10:28:11 +0300 Subject: [PATCH] Tidy the example code and ensure it builds as standalone snippets --- clippy_lints/src/operators/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/operators/mod.rs b/clippy_lints/src/operators/mod.rs index 32323f657b0..bf7a581c848 100644 --- a/clippy_lints/src/operators/mod.rs +++ b/clippy_lints/src/operators/mod.rs @@ -606,6 +606,11 @@ declare_clippy_lint! { /// For the scenario where you can define a meaningful absolute error margin, consider using: /// /// ```no_run + /// let a: f64 = 1000.1; + /// let b: f64 = 0.2; + /// let x = a + b; + /// let y = 1000.3; // Expected value. + /// /// const ALLOWED_ERROR_VEHICLE_LENGTH_CM: f64 = 0.1; /// let within_tolerance = (x - y).abs() < ALLOWED_ERROR_VEHICLE_LENGTH_CM; /// println!("{within_tolerance}"); // true @@ -647,7 +652,7 @@ declare_clippy_lint! { /// // Actual value: 1000.3000000000001 /// println!("{x}"); /// - /// let are_equal = x == y; + /// let are_equal = x == Y; /// println!("{are_equal}"); // false /// ``` /// @@ -664,6 +669,11 @@ declare_clippy_lint! { /// For the scenario where you can define a meaningful absolute error margin, consider using: /// /// ```no_run + /// let a: f64 = 1000.1; + /// let b: f64 = 0.2; + /// let x = a + b; + /// const Y: f64 = 1000.3; // Expected value. + /// /// const ALLOWED_ERROR_VEHICLE_LENGTH_CM: f64 = 0.1; /// let within_tolerance = (x - Y).abs() < ALLOWED_ERROR_VEHICLE_LENGTH_CM; /// println!("{within_tolerance}"); // true