Skip to content

Commit

Permalink
Use strip_prefix to please clippy
Browse files Browse the repository at this point in the history
This fixes the following clippy warning:

error: stripping a prefix manually
   --> src/cursor/find_cursor.rs:266:36
    |
266 |                     let mut path = &path[1..];
    |                                    ^^^^^^^^^^
    |
    = note: `-D clippy::manual-strip` implied by `-D warnings`
note: the prefix was tested here
   --> src/cursor/find_cursor.rs:264:17
    |
264 |                 if path.starts_with('~') {
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
help: try using the `strip_prefix` method
    |
264 ~                 if let Some(<stripped>) = path.strip_prefix('~') {
265 |                     theme_dir.push(&home);
266 ~                     let mut path = <stripped>;
    |

Signed-off-by: Uli Schlachter <psychon@znc.in>
  • Loading branch information
psychon committed Jan 30, 2022
1 parent aab6428 commit e1527ed
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/cursor/find_cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,8 @@ where
// Calculate the path to the theme's directory
let mut theme_dir = PathBuf::new();
// Does the path begin with '~'?
if path.starts_with('~') {
if let Some(mut path) = path.strip_prefix('~') {
theme_dir.push(&home);
let mut path = &path[1..];
// Skip a path separator if there is one
if path.chars().next().map(std::path::is_separator) == Some(true) {
path = &path[1..];
Expand Down

0 comments on commit e1527ed

Please sign in to comment.