1
0
mirror of https://github.com/sharkdp/bat.git synced 2025-04-14 06:40:39 +01:00

use explicit dyn with Write to appease compiler

This commit is contained in:
Wild Kat 2019-08-02 09:14:57 +02:00 committed by David Peter
parent 21821f1d4c
commit 28266ee441
3 changed files with 13 additions and 13 deletions

View File

@ -76,7 +76,7 @@ impl<'b> Controller<'b> {
&self, &self,
reader: InputFileReader, reader: InputFileReader,
printer: &mut P, printer: &mut P,
writer: &mut Write, writer: &mut dyn Write,
input_file: InputFile<'a>, input_file: InputFile<'a>,
) -> Result<()> { ) -> Result<()> {
printer.print_header(writer, input_file)?; printer.print_header(writer, input_file)?;
@ -91,7 +91,7 @@ impl<'b> Controller<'b> {
fn print_file_ranges<P: Printer>( fn print_file_ranges<P: Printer>(
&self, &self,
printer: &mut P, printer: &mut P,
writer: &mut Write, writer: &mut dyn Write,
mut reader: InputFileReader, mut reader: InputFileReader,
line_ranges: &LineRanges, line_ranges: &LineRanges,
) -> Result<()> { ) -> Result<()> {

View File

@ -98,7 +98,7 @@ impl OutputType {
OutputType::Stdout(io::stdout()) OutputType::Stdout(io::stdout())
} }
pub fn handle(&mut self) -> Result<&mut Write> { pub fn handle(&mut self) -> Result<&mut dyn Write> {
Ok(match *self { Ok(match *self {
OutputType::Pager(ref mut command) => command OutputType::Pager(ref mut command) => command
.stdin .stdin

View File

@ -30,12 +30,12 @@ use crate::style::OutputWrap;
use crate::terminal::{as_terminal_escaped, to_ansi_color}; use crate::terminal::{as_terminal_escaped, to_ansi_color};
pub trait Printer { pub trait Printer {
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()>; fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()>;
fn print_footer(&mut self, handle: &mut Write) -> Result<()>; fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()>;
fn print_line( fn print_line(
&mut self, &mut self,
out_of_range: bool, out_of_range: bool,
handle: &mut Write, handle: &mut dyn Write,
line_number: usize, line_number: usize,
line_buffer: &[u8], line_buffer: &[u8],
) -> Result<()>; ) -> Result<()>;
@ -50,18 +50,18 @@ impl SimplePrinter {
} }
impl Printer for SimplePrinter { impl Printer for SimplePrinter {
fn print_header(&mut self, _handle: &mut Write, _file: InputFile) -> Result<()> { fn print_header(&mut self, _handle: &mut dyn Write, _file: InputFile) -> Result<()> {
Ok(()) Ok(())
} }
fn print_footer(&mut self, _handle: &mut Write) -> Result<()> { fn print_footer(&mut self, _handle: &mut dyn Write) -> Result<()> {
Ok(()) Ok(())
} }
fn print_line( fn print_line(
&mut self, &mut self,
out_of_range: bool, out_of_range: bool,
handle: &mut Write, handle: &mut dyn Write,
_line_number: usize, _line_number: usize,
line_buffer: &[u8], line_buffer: &[u8],
) -> Result<()> { ) -> Result<()> {
@ -166,7 +166,7 @@ impl<'a> InteractivePrinter<'a> {
} }
} }
fn print_horizontal_line(&mut self, handle: &mut Write, grid_char: char) -> Result<()> { fn print_horizontal_line(&mut self, handle: &mut dyn Write, grid_char: char) -> Result<()> {
if self.panel_width == 0 { if self.panel_width == 0 {
writeln!( writeln!(
handle, handle,
@ -192,7 +192,7 @@ impl<'a> InteractivePrinter<'a> {
} }
impl<'a> Printer for InteractivePrinter<'a> { impl<'a> Printer for InteractivePrinter<'a> {
fn print_header(&mut self, handle: &mut Write, file: InputFile) -> Result<()> { fn print_header(&mut self, handle: &mut dyn Write, file: InputFile) -> Result<()> {
if !self.config.output_components.header() { if !self.config.output_components.header() {
if Some(ContentType::BINARY) == self.content_type { if Some(ContentType::BINARY) == self.content_type {
let input = match file { let input = match file {
@ -262,7 +262,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
Ok(()) Ok(())
} }
fn print_footer(&mut self, handle: &mut Write) -> Result<()> { fn print_footer(&mut self, handle: &mut dyn Write) -> Result<()> {
if self.config.output_components.grid() && self.content_type.map_or(false, |c| c.is_text()) if self.config.output_components.grid() && self.content_type.map_or(false, |c| c.is_text())
{ {
self.print_horizontal_line(handle, '┴') self.print_horizontal_line(handle, '┴')
@ -274,7 +274,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
fn print_line( fn print_line(
&mut self, &mut self,
out_of_range: bool, out_of_range: bool,
handle: &mut Write, handle: &mut dyn Write,
line_number: usize, line_number: usize,
line_buffer: &[u8], line_buffer: &[u8],
) -> Result<()> { ) -> Result<()> {