mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-19 04:21:06 +00:00
Revert "replace trait object BufRead by generic"
This reverts commit 037861e58886fd8220714a1f358de6663549b360.
This commit is contained in:
parent
5c95b8803b
commit
b191691767
@ -86,34 +86,25 @@ fn print_file(
|
||||
printer: &mut Printer,
|
||||
filename: Option<&str>,
|
||||
) -> Result<()> {
|
||||
printer.print_header(filename)?;
|
||||
let stdin = io::stdin(); // TODO: this is not always needed
|
||||
{
|
||||
let reader: Box<BufRead> = match filename {
|
||||
None => Box::new(stdin.lock()),
|
||||
Some(filename) => Box::new(BufReader::new(File::open(filename)?)),
|
||||
};
|
||||
|
||||
let highlighter = HighlightLines::new(syntax, theme);
|
||||
match filename {
|
||||
None => {
|
||||
let stdin = io::stdin(); // TODO: this is not always needed
|
||||
print_file_ranges(
|
||||
printer,
|
||||
stdin.lock(),
|
||||
highlighter,
|
||||
&printer.config.line_range,
|
||||
)?;
|
||||
}
|
||||
Some(filename) => print_file_ranges(
|
||||
printer,
|
||||
BufReader::new(File::open(filename)?),
|
||||
highlighter,
|
||||
&printer.config.line_range,
|
||||
)?,
|
||||
let highlighter = HighlightLines::new(syntax, theme);
|
||||
|
||||
printer.print_header(filename)?;
|
||||
print_file_ranges(printer, reader, highlighter, &printer.config.line_range)?;
|
||||
printer.print_footer()?;
|
||||
}
|
||||
|
||||
printer.print_footer()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn print_file_ranges<T: BufRead>(
|
||||
fn print_file_ranges<'a>(
|
||||
printer: &mut Printer,
|
||||
mut reader: T,
|
||||
mut reader: Box<BufRead + 'a>,
|
||||
mut highlighter: HighlightLines,
|
||||
line_ranges: &Option<LineRange>,
|
||||
) -> Result<()> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user