From e1527edecdcddec218631c15685e31b0c60de39b Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 30 Jan 2022 16:25:43 +0100 Subject: [PATCH] Use strip_prefix to please clippy 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() = path.strip_prefix('~') { 265 | theme_dir.push(&home); 266 ~ let mut path = ; | Signed-off-by: Uli Schlachter --- src/cursor/find_cursor.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cursor/find_cursor.rs b/src/cursor/find_cursor.rs index a8c63640..44681c91 100644 --- a/src/cursor/find_cursor.rs +++ b/src/cursor/find_cursor.rs @@ -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..];