mirror of
https://github.com/sharkdp/bat
synced 2024-11-27 06:10:20 +00:00
use io::Empty instead of crafted dummy stdin struct
This commit is contained in:
parent
deb80af449
commit
f28d9db3d0
1 changed files with 2 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
|||
use std::io::{self, BufRead, Read, Write};
|
||||
use std::io::{self, BufRead, Write};
|
||||
|
||||
use crate::assets::HighlightingAssets;
|
||||
use crate::config::{Config, VisibleLines};
|
||||
|
@ -16,19 +16,6 @@ use crate::printer::{InteractivePrinter, Printer, SimplePrinter};
|
|||
|
||||
use clircle::{Clircle, Identifier};
|
||||
|
||||
struct DummyStdin;
|
||||
impl Read for DummyStdin {
|
||||
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
||||
Ok(buf.len())
|
||||
}
|
||||
}
|
||||
impl BufRead for DummyStdin {
|
||||
fn fill_buf(&mut self) -> io::Result<&[u8]> {
|
||||
Ok(&[])
|
||||
}
|
||||
fn consume(&mut self, _amt: usize) {}
|
||||
}
|
||||
|
||||
pub struct Controller<'a> {
|
||||
config: &'a Config<'a>,
|
||||
assets: &'a HighlightingAssets,
|
||||
|
@ -98,7 +85,7 @@ impl<'b> Controller<'b> {
|
|||
self.print_input(input, writer, io::stdin().lock(), identifier, is_first)
|
||||
} else {
|
||||
// Use dummy stdin since stdin is actually not used (#1902)
|
||||
self.print_input(input, writer, DummyStdin, identifier, is_first)
|
||||
self.print_input(input, writer, io::empty(), identifier, is_first)
|
||||
};
|
||||
if let Err(error) = result {
|
||||
if attached_to_pager {
|
||||
|
|
Loading…
Reference in a new issue