mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
tail: Take ownership of the provided BufReader<T>
The `BufReader` argument passed to the `fn tail<T: Read>(&mut BufReader<T>, settings: &settings)` function is never reused, so the `tail` function should just take ownership of it.
This commit is contained in:
parent
bbd55b283a
commit
977742f209
1 changed files with 6 additions and 6 deletions
10
src/tail/tail.rs
Normal file → Executable file
10
src/tail/tail.rs
Normal file → Executable file
|
@ -134,8 +134,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
let files = given_options.free;
|
||||
|
||||
if files.is_empty() {
|
||||
let mut buffer = BufReader::new(stdin());
|
||||
tail(&mut buffer, &settings);
|
||||
let buffer = BufReader::new(stdin());
|
||||
tail(buffer, &settings);
|
||||
} else {
|
||||
let mut multiple = false;
|
||||
let mut firstime = true;
|
||||
|
@ -153,8 +153,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
|
|||
|
||||
let path = Path::new(file);
|
||||
let reader = File::open(&path).unwrap();
|
||||
let mut buffer = BufReader::new(reader);
|
||||
tail(&mut buffer, &settings);
|
||||
let buffer = BufReader::new(reader);
|
||||
tail(buffer, &settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ fn obsolete(options: &[String]) -> (Vec<String>, Option<usize>) {
|
|||
(options, None)
|
||||
}
|
||||
|
||||
fn tail<T: Read>(reader: &mut BufReader<T>, settings: &Settings) {
|
||||
fn tail<T: Read>(mut reader: BufReader<T>, settings: &Settings) {
|
||||
// Read through each line/char and store them in a ringbuffer that always
|
||||
// contains count lines/chars. When reaching the end of file, output the
|
||||
// data in the ringbuf.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue