Skip to content

Commit

Permalink
Fixed the 'ptr_arg' clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ZapAnton committed Oct 31, 2019
1 parent d868275 commit 065d65a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/ascii_art.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<'a> Tokens<'a> {
})
}
/// render a truncated line of tokens.
fn render(self, colors: &Vec<Color>, start: usize, end: usize, bold: bool) -> String {
fn render(self, colors: &[Color], start: usize, end: usize, bold: bool) -> String {
assert!(start <= end);
let mut width = end - start;
let mut colored_segment = String::new();
Expand All @@ -169,7 +169,7 @@ impl<'a> Tokens<'a> {
colored_segment.push(chr);
}
Token::Color(col) => {
add_colored_segment(&mut whole_string, &colored_segment, color, bold);
add_colored_segment(&mut whole_string, &colored_segment, *color, bold);
colored_segment = String::new();
color = colors.get(col as usize).unwrap_or(&Color::White);
}
Expand All @@ -180,7 +180,7 @@ impl<'a> Tokens<'a> {
};
});

add_colored_segment(&mut whole_string, &colored_segment, color, bold);
add_colored_segment(&mut whole_string, &colored_segment, *color, bold);
(0..width).for_each(|_| whole_string.push(' '));
whole_string
}
Expand All @@ -198,8 +198,8 @@ fn succeed_when<I>(predicate: impl FnOnce(I) -> bool) -> impl FnOnce(I) -> Optio
}
}

fn add_colored_segment(base: &mut String, segment: &String, color: &Color, bold: bool) {
let mut colored_segment = segment.color(*color);
fn add_colored_segment(base: &mut String, segment: &str, color: Color, bold: bool) {
let mut colored_segment = segment.color(color);
if bold {
colored_segment = colored_segment.bold();
}
Expand Down

0 comments on commit 065d65a

Please sign in to comment.