diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs index 674f2929e0..0d68ba40d9 100644 --- a/src/pretty_printer.rs +++ b/src/pretty_printer.rs @@ -229,14 +229,6 @@ impl<'a> PrettyPrinter<'a> { self } - /// Clear highlighted lines added by [`PrettyPrinter::highlight`] and - /// [`PrettyPrinter::highlight_range`]. This is useful when reusing a - /// `PrettyPrinter` instance for multiple different ranges. - pub fn clear_highlights(&mut self) -> &mut Self { - self.highlighted_lines.clear(); - self - } - /// Specify the highlighting theme pub fn theme(&mut self, theme: impl AsRef) -> &mut Self { self.config.theme = theme.as_ref().to_owned(); @@ -271,8 +263,8 @@ impl<'a> PrettyPrinter<'a> { /// If you want to call 'print' multiple times, you have to call the appropriate /// input_* methods again. pub fn print(&mut self) -> Result { - self.config.highlighted_lines = - HighlightedLineRanges(LineRanges::from(self.highlighted_lines.clone())); + let highlight_lines = std::mem::take(&mut self.highlighted_lines); + self.config.highlighted_lines = HighlightedLineRanges(LineRanges::from(highlight_lines)); self.config.term_width = self .term_width .unwrap_or_else(|| Term::stdout().size().1 as usize);