diff --git a/src/ascii_art.rs b/src/ascii_art.rs index 2492abfc0..5f7aa856b 100644 --- a/src/ascii_art.rs +++ b/src/ascii_art.rs @@ -155,7 +155,7 @@ impl<'a> Tokens<'a> { }) } /// render a truncated line of tokens. - fn render(self, colors: &Vec, 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(); @@ -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); } @@ -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 } @@ -198,8 +198,8 @@ fn succeed_when(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(); }