mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-28 08:05:52 +00:00
Remove unnecessary RefCell, backport to Rust 1.36
This commit is contained in:
1 parent
244f71691d
commit
133fdd9156
4 files changed
+7
-9
No files matched your search
+4
-5
@@ -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),
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user