mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Tidy the example code and ensure it builds as standalone snippets
This commit is contained in:
parent
a067cd24ac
commit
a04dbb0ab9
1 changed files with 11 additions and 1 deletions
|
@ -606,6 +606,11 @@ declare_clippy_lint! {
|
||||||
/// For the scenario where you can define a meaningful absolute error margin, consider using:
|
/// For the scenario where you can define a meaningful absolute error margin, consider using:
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```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;
|
/// const ALLOWED_ERROR_VEHICLE_LENGTH_CM: f64 = 0.1;
|
||||||
/// let within_tolerance = (x - y).abs() < ALLOWED_ERROR_VEHICLE_LENGTH_CM;
|
/// let within_tolerance = (x - y).abs() < ALLOWED_ERROR_VEHICLE_LENGTH_CM;
|
||||||
/// println!("{within_tolerance}"); // true
|
/// println!("{within_tolerance}"); // true
|
||||||
|
@ -647,7 +652,7 @@ declare_clippy_lint! {
|
||||||
/// // Actual value: 1000.3000000000001
|
/// // Actual value: 1000.3000000000001
|
||||||
/// println!("{x}");
|
/// println!("{x}");
|
||||||
///
|
///
|
||||||
/// let are_equal = x == y;
|
/// let are_equal = x == Y;
|
||||||
/// println!("{are_equal}"); // false
|
/// 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:
|
/// For the scenario where you can define a meaningful absolute error margin, consider using:
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```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;
|
/// const ALLOWED_ERROR_VEHICLE_LENGTH_CM: f64 = 0.1;
|
||||||
/// let within_tolerance = (x - Y).abs() < ALLOWED_ERROR_VEHICLE_LENGTH_CM;
|
/// let within_tolerance = (x - Y).abs() < ALLOWED_ERROR_VEHICLE_LENGTH_CM;
|
||||||
/// println!("{within_tolerance}"); // true
|
/// println!("{within_tolerance}"); // true
|
||||||
|
|
Loading…
Reference in a new issue