Skip to main content

Lint clippy::range_plus_one

warning clippy::range_plus_one §

an inclusive range would be more readable

src/render/paths.rs:103:28

Clippy · Category: pedantic · cargo-clippy-html

Official Clippy documentation

Targets (1)
  • cargo-clippy-html (bin)

Primary: src/render/paths.rs:103:28

        name.replace_range(dot..dot + 1, "~2E");

help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#range_plus_one

note: `-W clippy::range-plus-one` implied by `-W clippy::pedantic`

help: to override `-W clippy::pedantic` add `#[allow(clippy::range_plus_one)]`

help: use

Suggestion: use

MachineApplicable

--- "a/src/render/paths.rs"
+++ "b/src/render/paths.rs"
@@ -100,7 +100,7 @@
     }
     if directory && name.to_ascii_lowercase().ends_with(".html") {
         let dot = name.len() - 5;
-        name.replace_range(dot..dot + 1, "~2E");
+        name.replace_range(dot..=dot, "~2E");
     }
     while name.ends_with('.') {
         name.pop();
Rendered diagnostic (text)
warning: an inclusive range would be more readable
   --> src/render/paths.rs:103:28
    |
103 |         name.replace_range(dot..dot + 1, "~2E");
    |                            ^^^^^^^^^^^^ help: use: `dot..=dot`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.100.0/index.html#range_plus_one
    = note: `-W clippy::range-plus-one` implied by `-W clippy::pedantic`
    = help: to override `-W clippy::pedantic` add `#[allow(clippy::range_plus_one)]`