Skip to content

Commit a04dbb0

Browse files
committed
Tidy the example code and ensure it builds as standalone snippets
1 parent a067cd2 commit a04dbb0

File tree

1 file changed

+11
-1
lines changed
  • clippy_lints/src/operators

1 file changed

+11
-1
lines changed

clippy_lints/src/operators/mod.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,11 @@ declare_clippy_lint! {
606606
/// For the scenario where you can define a meaningful absolute error margin, consider using:
607607
///
608608
/// ```no_run
609+
/// let a: f64 = 1000.1;
610+
/// let b: f64 = 0.2;
611+
/// let x = a + b;
612+
/// let y = 1000.3; // Expected value.
613+
///
609614
/// const ALLOWED_ERROR_VEHICLE_LENGTH_CM: f64 = 0.1;
610615
/// let within_tolerance = (x - y).abs() < ALLOWED_ERROR_VEHICLE_LENGTH_CM;
611616
/// println!("{within_tolerance}"); // true
@@ -647,7 +652,7 @@ declare_clippy_lint! {
647652
/// // Actual value: 1000.3000000000001
648653
/// println!("{x}");
649654
///
650-
/// let are_equal = x == y;
655+
/// let are_equal = x == Y;
651656
/// println!("{are_equal}"); // false
652657
/// ```
653658
///
@@ -664,6 +669,11 @@ declare_clippy_lint! {
664669
/// For the scenario where you can define a meaningful absolute error margin, consider using:
665670
///
666671
/// ```no_run
672+
/// let a: f64 = 1000.1;
673+
/// let b: f64 = 0.2;
674+
/// let x = a + b;
675+
/// const Y: f64 = 1000.3; // Expected value.
676+
///
667677
/// const ALLOWED_ERROR_VEHICLE_LENGTH_CM: f64 = 0.1;
668678
/// let within_tolerance = (x - Y).abs() < ALLOWED_ERROR_VEHICLE_LENGTH_CM;
669679
/// println!("{within_tolerance}"); // true

0 commit comments

Comments
 (0)