1
0
mirror of https://github.com/sharkdp/bat synced 2026-08-06 19:21:43 +00:00

Pass stdin as a generic BufRead, fix stdin tests

This commit is contained in:
sharkdp
2020-04-18 11:37:12 +02:00
committed by David Peter
parent d5a31dc2ec
commit 1b8ce60054
3 changed files with 17 additions and 8 deletions
+2 -2
View File
@@ -86,9 +86,9 @@ pub enum InputFile<'a> {
}
impl<'a> InputFile<'a> {
pub(crate) fn get_reader(&self, stdin: &'a io::Stdin) -> Result<InputFileReader> {
pub(crate) fn get_reader<R: BufRead + 'a>(&self, stdin: R) -> Result<InputFileReader> {
match self {
InputFile::StdIn(_) => Ok(InputFileReader::new(stdin.lock())),
InputFile::StdIn(_) => Ok(InputFileReader::new(stdin)),
InputFile::Ordinary(ofile) => {
let file = File::open(ofile.path)
.map_err(|e| format!("'{}': {}", ofile.path.to_string_lossy(), e))?;