Skip to content

Commit

Permalink
Merge pull request #410 from mgeisler/clippy
Browse files Browse the repository at this point in the history
Cleanup needless borrows
  • Loading branch information
mgeisler authored Jul 9, 2021
2 parents 0e830cb + 474be42 commit 172567e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl<'a> Word<'a> {
let trimmed = word.trim_end_matches(' ');
Word {
word: trimmed,
width: display_width(&trimmed),
width: display_width(trimmed),
whitespace: &word[trimmed.len()..],
penalty: "",
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ where
if i > 0 {
result.push('\n');
}
result.push_str(&line);
result.push_str(line);
}

result
Expand Down Expand Up @@ -1089,7 +1089,7 @@ where
result += &line[idx..idx + len];

if !last_word.penalty.is_empty() {
result.to_mut().push_str(&last_word.penalty);
result.to_mut().push_str(last_word.penalty);
}

lines.push(result);
Expand Down Expand Up @@ -1197,8 +1197,8 @@ where
for column_no in 0..columns {
match wrapped_lines.get(line_no + column_no * lines_per_column) {
Some(column_line) => {
line.push_str(&column_line);
line.push_str(&" ".repeat(column_width - core::display_width(&column_line)));
line.push_str(column_line);
line.push_str(&" ".repeat(column_width - core::display_width(column_line)));
}
None => {
line.push_str(&" ".repeat(column_width));
Expand Down
2 changes: 1 addition & 1 deletion src/word_separators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ impl WordSeparator for UnicodeBreakProperties {
None => None,
});

let stripped = strip_ansi_escape_sequences(&line);
let stripped = strip_ansi_escape_sequences(line);
let mut opportunities = unicode_linebreak::linebreaks(&stripped)
.filter(|(idx, _)| {
#[allow(clippy::match_like_matches_macro)]
Expand Down
6 changes: 3 additions & 3 deletions src/wrap_algorithms/optimal_fit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl Default for OptimalFit {
impl WrapAlgorithm for OptimalFit {
#[inline]
fn wrap<'a, 'b>(&self, words: &'b [Word<'a>], line_widths: &'b [usize]) -> Vec<&'b [Word<'a>]> {
wrap_optimal_fit(words, line_widths, &self)
wrap_optimal_fit(words, line_widths, self)
}
}

Expand All @@ -183,7 +183,7 @@ impl LineNumbers {
fn get<T>(&self, i: usize, minima: &[(usize, T)]) -> usize {
while self.line_numbers.borrow_mut().len() < i + 1 {
let pos = self.line_numbers.borrow().len();
let line_number = 1 + self.get(minima[pos].0, &minima);
let line_number = 1 + self.get(minima[pos].0, minima);
self.line_numbers.borrow_mut().push(line_number);
}

Expand Down Expand Up @@ -285,7 +285,7 @@ pub fn wrap_optimal_fit<'a, 'b, T: Fragment>(

let minima = smawk::online_column_minima(0, widths.len(), |minima, i, j| {
// Line number for fragment `i`.
let line_number = line_numbers.get(i, &minima);
let line_number = line_numbers.get(i, minima);
let line_width = line_widths
.get(line_number)
.copied()
Expand Down

0 comments on commit 172567e

Please sign in to comment.