From 8a671168576b9b552a22be285646fc293a80d8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 21 Mar 2021 12:38:21 +0100 Subject: use strip_prefix() instead of starts_with and slicing (clippy::manual_strip) --- crates/hir_expand/src/name.rs | 5 ++--- crates/syntax/src/ast/edit.rs | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'crates') diff --git a/crates/hir_expand/src/name.rs b/crates/hir_expand/src/name.rs index 43de9edd6..0aeea48d5 100644 --- a/crates/hir_expand/src/name.rs +++ b/crates/hir_expand/src/name.rs @@ -48,9 +48,8 @@ impl Name { /// Resolve a name from the text of token. fn resolve(raw_text: &str) -> Name { - let raw_start = "r#"; - if raw_text.starts_with(raw_start) { - Name::new_text(SmolStr::new(&raw_text[raw_start.len()..])) + if let Some(text) = raw_text.strip_prefix("r#") { + Name::new_text(SmolStr::new(text)) } else { Name::new_text(raw_text.into()) } diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs index 64fac13a7..80be8b79c 100644 --- a/crates/syntax/src/ast/edit.rs +++ b/crates/syntax/src/ast/edit.rs @@ -333,8 +333,7 @@ impl ast::Use { .and_then(ast::Whitespace::cast); if let Some(next_ws) = next_ws { let ws_text = next_ws.syntax().text(); - if ws_text.starts_with('\n') { - let rest = &ws_text[1..]; + if let Some(rest) = ws_text.strip_prefix('\n') { if rest.is_empty() { res.delete(next_ws.syntax()) } else { -- cgit v1.2.3