|
8 | 8 | use clap::{Arg, ArgAction, Command}; |
9 | 9 | use std::ffi::OsString; |
10 | 10 | use std::fs::File; |
11 | | -use std::io::{self, ErrorKind, Read, Seek}; |
| 11 | +use std::io::{self, ErrorKind, Read}; |
12 | 12 | use std::path::{Path, PathBuf}; |
13 | 13 | use uucore::display::Quotable; |
14 | 14 | use uucore::encoding::{ |
@@ -149,29 +149,19 @@ pub fn base_app(about: &'static str, usage: &str) -> Command { |
149 | 149 | ) |
150 | 150 | } |
151 | 151 |
|
152 | | -/// A trait alias for types that implement both `Read` and `Seek`. |
153 | | -pub trait ReadSeek: Read + Seek {} |
154 | | - |
155 | | -/// Automatically implement the `ReadSeek` trait for any type that implements both `Read` and `Seek`. |
156 | | -impl<T: Read + Seek> ReadSeek for T {} |
157 | | - |
158 | | -pub fn get_input(config: &Config) -> UResult<Box<dyn ReadSeek>> { |
| 152 | +pub fn get_input(config: &Config) -> UResult<Box<dyn Read>> { |
159 | 153 | match &config.to_read { |
160 | 154 | Some(path_buf) => { |
161 | 155 | // Do not buffer input, because buffering is handled by `fast_decode` and `fast_encode` |
162 | 156 | let file = |
163 | 157 | File::open(path_buf).map_err_context(|| path_buf.maybe_quote().to_string())?; |
164 | 158 | Ok(Box::new(file)) |
165 | 159 | } |
166 | | - None => { |
167 | | - let mut buffer = Vec::new(); |
168 | | - io::stdin().read_to_end(&mut buffer)?; |
169 | | - Ok(Box::new(io::Cursor::new(buffer))) |
170 | | - } |
| 160 | + None => Ok(Box::new(io::stdin())), |
171 | 161 | } |
172 | 162 | } |
173 | 163 |
|
174 | | -pub fn handle_input<R: Read + Seek>(input: &mut R, format: Format, config: Config) -> UResult<()> { |
| 164 | +pub fn handle_input<R: Read>(input: &mut R, format: Format, config: Config) -> UResult<()> { |
175 | 165 | let supports_fast_decode_and_encode = get_supports_fast_decode_and_encode(format); |
176 | 166 |
|
177 | 167 | let supports_fast_decode_and_encode_ref = supports_fast_decode_and_encode.as_ref(); |
|
0 commit comments