Remove unnecessary RefCell, backport to Rust 1.36

This commit is contained in:
sharkdp authored and David Peter committed 2020-05-13 18:55:24 +02:00
1 parent 244f71691d
commit 133fdd9156
4 files changed
+7 -9

No files matched your search

+4 -5
View File
@@ -1,17 +1,16 @@
use std::cell::RefCell;
use std::fs;
use std::io::{self, Read, Seek, SeekFrom};
pub enum Input<'a> {
File(fs::File),
Stdin(RefCell<io::StdinLock<'a>>),
Stdin(io::StdinLock<'a>),
}
impl<'a> Read for Input<'a> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
match *self {
Input::File(ref mut file) => file.read(buf),
Input::Stdin(ref mut stdin) => stdin.borrow_mut().read(buf),
Input::Stdin(ref mut stdin) => stdin.read(buf),
}
}
}
@@ -31,8 +30,8 @@ impl<'a> Seek for Input<'a> {
impl<'a> Input<'a> {
pub fn into_inner(self) -> Box<dyn Read + 'a> {
match self {
Self::File(file) => Box::new(file),
Self::Stdin(stdin) => Box::new(stdin.into_inner()),
Input::File(file) => Box::new(file),
Input::Stdin(stdin) => Box::new(stdin),
}
}
}