refactor: clippy::deref_by_slicing (#974)

This commit is contained in:
EdJoPaTo 2024-02-27 14:08:06 +01:00 committed by Josh McKinney
parent b831c5688c
commit 36a0cd56e5
No known key found for this signature in database
GPG Key ID: 722287396A903BC5
2 changed files with 6 additions and 8 deletions

View File

@ -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"

View File

@ -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);