Skip to content

Commit

Permalink
[Clippy] Use *TruncatedStrView instead of TruncatedStrView.clone()
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJuliusMartinez committed Feb 9, 2022
1 parent f30d3ca commit 3c1efd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/lineprinter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ impl<'a, 'b, 'c> LinePrinter<'a, 'b, 'c> {
.cached_formatted_value
.take()
.map(|entry| {
entry
*entry
.and_modify(|tsv| {
*tsv = tsv.resize(value_ref, available_space);
})
Expand Down Expand Up @@ -508,7 +508,6 @@ impl<'a, 'b, 'c> LinePrinter<'a, 'b, 'c> {

tsv.focus(value_ref, &offset_focused_range)
})
.clone()
})
.unwrap_or_else(|| TruncatedStrView::init_start(value_ref, available_space));

Expand Down
12 changes: 6 additions & 6 deletions src/truncatedstrview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl TruncatedStrView {
/// number of characters (unless the end of the string is reached).
pub fn scroll_right(&self, s: &str, count: usize) -> TruncatedStrView {
if self.range.is_none() {
return self.clone();
return *self;
}

// If we only have two columns, we can't represent the middle
Expand Down Expand Up @@ -247,7 +247,7 @@ impl TruncatedStrView {
/// number of characters (unless the start of the string is reached).
pub fn scroll_left(&self, s: &str, count: usize) -> TruncatedStrView {
if self.range.is_none() {
return self.clone();
return *self;
}

// If we only have two columns, we can't represent the middle
Expand Down Expand Up @@ -285,7 +285,7 @@ impl TruncatedStrView {
/// will jump to the front.
pub fn jump_to_an_end(&self, s: &str) -> TruncatedStrView {
match self.range {
None => self.clone(),
None => *self,
Some(range) => {
if range.end < s.len() {
TruncatedStrView::init_back(s, self.available_space)
Expand All @@ -311,7 +311,7 @@ impl TruncatedStrView {
} else if available_space > self.available_space {
self.expand(s, available_space)
} else {
self.clone()
*self
}
}

Expand Down Expand Up @@ -383,7 +383,7 @@ impl TruncatedStrView {
/// Scroll a view so that a particular subrange is shown.
pub fn focus(&self, s: &str, range: &Range<usize>) -> TruncatedStrView {
if self.range.is_none() {
return self.clone();
return *self;
}

let Range { mut start, mut end } = *range;
Expand All @@ -398,7 +398,7 @@ impl TruncatedStrView {

// If the entire match is already visible, don't do anything.
if visible_range.start <= start && end <= visible_range.end {
return self.clone();
return *self;
}

// But otherwise, we'll just jump to the match and try to center it.
Expand Down

0 comments on commit 3c1efd2

Please sign in to comment.