mirror of
https://github.com/sharkdp/hexyl.git
synced 2026-10-26 20:16:34 +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
+1
-1
@@ -18,7 +18,7 @@ matrix:
|
||||
|
||||
# Minimum Rust supported channel.
|
||||
- os: linux
|
||||
rust: 1.31.0
|
||||
rust: 1.36.0
|
||||
env: TARGET=x86_64-unknown-linux-gnu
|
||||
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ or Windows Terminal since Windows 10 1903).
|
||||
|
||||
### Via cargo
|
||||
|
||||
If you have Rust 1.31 or higher, you can install `hexyl` from source via `cargo`:
|
||||
If you have Rust 1.36 or higher, you can install `hexyl` from source via `cargo`:
|
||||
```
|
||||
cargo install hexyl
|
||||
```
|
||||
|
||||
+1
-2
@@ -3,7 +3,6 @@ extern crate clap;
|
||||
|
||||
use atty;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::fs::File;
|
||||
use std::io::{self, prelude::*, SeekFrom};
|
||||
|
||||
@@ -91,7 +90,7 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
let mut reader: Input = match matches.value_of("file") {
|
||||
Some(filename) => Input::File(File::open(filename)?),
|
||||
None => Input::Stdin(RefCell::new(stdin.lock())),
|
||||
None => Input::Stdin(stdin.lock()),
|
||||
};
|
||||
|
||||
let skip_arg = matches.value_of("skip");
|
||||
|
||||
+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