on master help sign in
use explicit dyn with Write to appease compiler
commit28266ee4418e8d4b34e0080a75463215b5387f68 authorWild Kat <wk@futureinquestion.net> dateFri 2 Aug 2019, 09:14 (7 years ago) parent21821f1
3 files changed+13−13
src/controller.rs+2−2 src/output.rs+1−1 src/printer.rs+10−10
src/controller.rs+2−2
@@ -76,7 +76,7 @@ impl<'b> Controller<'b> {
7676 &self,
7777 reader: InputFileReader,
7878 printer: &mut P,
79− writer: &mut Write,
79+ writer: &mut dyn Write,
8080 input_file: InputFile<'a>,
8181 ) -> Result<()> {
8282 printer.print_header(writer, input_file)?;
@@ -91,7 +91,7 @@ impl<'b> Controller<'b> {
9191 fn print_file_ranges<P: Printer>(
9292 &self,
9393 printer: &mut P,
94− writer: &mut Write,
94+ writer: &mut dyn Write,
9595 mut reader: InputFileReader,
9696 line_ranges: &LineRanges,
9797 ) -> Result<()> {
src/output.rs+1−1
@@ -98,7 +98,7 @@ impl OutputType {
9898 OutputType::Stdout(io::stdout())
9999 }
100100
101− pub fn handle(&mut self) -> Result<&mut Write> {
101+ pub fn handle(&mut self) -> Result<&mut dyn Write> {
102102 Ok(match *self {
103103 OutputType::Pager(ref mut command) => command
104104 .stdin
src/printer.rs+10−10
@@ -30,12 +30,12 @@ use crate::style::OutputWrap;
3030use crate::terminal::{as_terminal_escaped, to_ansi_color};
3131
3232pub trait Printer {
33− fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()>;
34− fn print_footer(&mut self, handle: &mut Write) -> Result<()>;
33+ fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
34+ fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()>;
3535 fn print_line(
3636 &mut self,
3737 out_of_range: bool,
38− handle: &mut Write,
38+ handle: &mut dyn Write,
3939 line_number: usize,
4040 line_buffer: &[u8],
4141 ) -> Result<()>;
@@ -50,18 +50,18 @@ impl SimplePrinter {
5050}
5151
5252impl Printer for SimplePrinter {
53− fn print_header(&mut self, _handle: &mut Write, _file: InputFile) -> Result<()> {
53+ fn print_header(&mut self, _handle: &mut dyn Write, _file: InputFile) -> Result<()> {
5454 Ok(())
5555 }
5656
57− fn print_footer(&mut self, _handle: &mut Write) -> Result<()> {
57+ fn print_footer(&mut self, _handle: &mut dyn Write) -> Result<()> {
5858 Ok(())
5959 }
6060
6161 fn print_line(
6262 &mut self,
6363 out_of_range: bool,
64− handle: &mut Write,
64+ handle: &mut dyn Write,
6565 _line_number: usize,
6666 line_buffer: &[u8],
6767 ) -> Result<()> {
@@ -166,7 +166,7 @@ impl<'a> InteractivePrinter<'a> {
166166 }
167167 }
168168
169− fn print_horizontal_line(&mut self, handle: &mut Write, grid_char: char) -> Result<()> {
169+ fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {
170170 if self.panel_width == 0 {
171171 writeln!(
172172 handle,
@@ -192,7 +192,7 @@ impl<'a> InteractivePrinter<'a> {
192192}
193193
194194impl<'a> Printer for InteractivePrinter<'a> {
195− fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()> {
195+ fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()> {
196196 if !self.config.output_components.header() {
197197 if Some(ContentType::BINARY) == self.content_type {
198198 let input = match file {
@@ -262,7 +262,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
262262 Ok(())
263263 }
264264
265− fn print_footer(&mut self, handle: &mut Write) -> Result<()> {
265+ fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()> {
266266 if self.config.output_components.grid() && self.content_type.map_or(false, |c| c.is_text())
267267 {
268268 self.print_horizontal_line(handle, '┴')
@@ -274,7 +274,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
274274 fn print_line(
275275 &mut self,
276276 out_of_range: bool,
277− handle: &mut Write,
277+ handle: &mut dyn Write,
278278 line_number: usize,
279279 line_buffer: &[u8],
280280 ) -> Result<()> {