From 36a0cd56e5645533a1d6c2720536fa10a56b0d40 Mon Sep 17 00:00:00 2001 From: EdJoPaTo Date: Tue, 27 Feb 2024 14:08:06 +0100 Subject: [PATCH] refactor: clippy::deref_by_slicing (#974) --- Cargo.toml | 1 + src/widgets/reflow.rs | 13 +++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8bdd32a5..386a5cb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,6 +66,7 @@ unsafe_code = "forbid" [lints.clippy] cloned_instead_of_copied = "warn" default_trait_access = "warn" +deref_by_slicing = "warn" equatable_if_let = "warn" explicit_iter_loop = "warn" implicit_clone = "warn" diff --git a/src/widgets/reflow.rs b/src/widgets/reflow.rs index 9af65919..260baba6 100644 --- a/src/widgets/reflow.rs +++ b/src/widgets/reflow.rs @@ -210,7 +210,7 @@ where if let Some(line) = current_line { self.current_line = line; Some(WrappedLine { - line: &self.current_line[..], + line: &self.current_line, width: line_width, alignment: self.current_alignment, }) @@ -310,7 +310,7 @@ where None } else { Some(WrappedLine { - line: &self.current_line[..], + line: &self.current_line, width: current_line_width, alignment: current_alignment, }) @@ -396,13 +396,10 @@ mod test { let width = 40; for i in 1..width { let text = "a".repeat(i); - let (word_wrapper, _, _) = run_composer( - Composer::WordWrapper { trim: true }, - &text[..], - width as u16, - ); + let (word_wrapper, _, _) = + run_composer(Composer::WordWrapper { trim: true }, &*text, width as u16); let (line_truncator, _, _) = - run_composer(Composer::LineTruncator, &text[..], width as u16); + run_composer(Composer::LineTruncator, &*text, width as u16); let expected = vec![text]; assert_eq!(word_wrapper, expected); assert_eq!(line_truncator, expected);