on master help sign in
Replace `Cow` by `String`
commit747d074be129f16c34633169b62414a3fa699d57 authorPit Kleyersburg <pitkley@googlemail.com> dateWed 9 May 2018, 22:31 (9 years ago) parent61109ec
1 file changed+14−19
src/printer.rs+14−19
src/printer.rs+14−19
@@ -1,6 +1,5 @@
11use ansi_term::Style;
22use errors::*;
3−use std::borrow::Cow;
43use std::io::Write;
54use syntect::highlighting;
65use terminal::as_terminal_escaped;
@@ -80,13 +79,11 @@ impl<'a> Printer<'a> {
8079 self.print_line_number(line_number),
8180 self.print_git_marker(line_number),
8281 self.print_line_border(),
83− Some(
84− as_terminal_escaped(
85− &regions,
86− self.options.true_color,
87− self.options.colored_output,
88− ).into(),
89− ),
82+ Some(as_terminal_escaped(
83+ &regions,
84+ self.options.true_color,
85+ self.options.colored_output,
86+ )),
9087 ];
9188
9289 let grid_requested = self.options.output_components.grid();
@@ -96,7 +93,7 @@ impl<'a> Printer<'a> {
9693 decorations
9794 .into_iter()
9895 .filter_map(|dec| if grid_requested {
99− Some(dec.unwrap_or(" ".into()))
96+ Some(dec.unwrap_or(" ".to_owned()))
10097 } else {
10198 dec
10299 })
@@ -107,23 +104,22 @@ impl<'a> Printer<'a> {
107104 Ok(())
108105 }
109106
110− fn print_line_number<'s>(&self, line_number: usize) -> Option<Cow<'s, str>> {
107+ fn print_line_number<'s>(&self, line_number: usize) -> Option<String> {
111108 if self.options.output_components.numbers() {
112109 Some(
113110 self.colors
114111 .line_number
115112 .paint(format!("{:4}", line_number))
116− .to_string()
117− .into(),
113+ .to_string(),
118114 )
119115 } else if self.options.output_components.grid() {
120− Some(" ".into())
116+ Some(" ".to_owned())
121117 } else {
122118 None
123119 }
124120 }
125121
126− fn print_git_marker<'s>(&self, line_number: usize) -> Option<Cow<'s, str>> {
122+ fn print_git_marker<'s>(&self, line_number: usize) -> Option<String> {
127123 if self.options.output_components.changes() {
128124 Some(
129125 if let Some(ref changes) = self.line_changes {
@@ -136,19 +132,18 @@ impl<'a> Printer<'a> {
136132 }
137133 } else {
138134 Style::default().paint(" ")
139− }.to_string()
140− .into(),
135+ }.to_string(),
141136 )
142137 } else if self.options.output_components.grid() {
143− Some(" ".into())
138+ Some(" ".to_owned())
144139 } else {
145140 None
146141 }
147142 }
148143
149− fn print_line_border<'s>(&self) -> Option<Cow<'s, str>> {
144+ fn print_line_border<'s>(&self) -> Option<String> {
150145 if self.options.output_components.grid() {
151− Some(self.colors.grid.paint("│").to_string().into())
146+ Some(self.colors.grid.paint("│").to_string())
152147 } else {
153148 None
154149 }