Skip to content

Commit 39b5760

Browse files
authored
Merge pull request #1307 from PaulCapron/master
Remove some useless BufReader wrappers around stdin
2 parents 1dc7d8c + 324cbad commit 39b5760

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/cp/cp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use clap::{App, Arg, ArgMatches};
3939
use quick_error::ResultExt;
4040
use std::collections::HashSet;
4141
use std::fs;
42-
use std::io::{stdin, stdout, BufRead, BufReader, Write};
42+
use std::io::{stdin, stdout, Write};
4343
use std::io;
4444
use std::path::{Path, PathBuf, StripPrefixError};
4545
use std::str::FromStr;
@@ -120,7 +120,7 @@ macro_rules! prompt_yes(
120120
print!(" [y/N]: ");
121121
crash_if_err!(1, stdout().flush());
122122
let mut s = String::new();
123-
match BufReader::new(stdin()).read_line(&mut s) {
123+
match stdin().read_line(&mut s) {
124124
Ok(_) => match s.char_indices().nth(0) {
125125
Some((_, x)) => x == 'y' || x == 'Y',
126126
_ => false

src/factor/factor.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use rand::distributions::{Distribution, Uniform};
2323
use rand::{SeedableRng, thread_rng};
2424
use rand::rngs::SmallRng;
2525
use std::cmp::{max, min};
26-
use std::io::{stdin, BufRead, BufReader};
26+
use std::io::{stdin, BufRead};
2727
use std::num::Wrapping;
2828
use std::mem::swap;
2929

@@ -163,7 +163,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
163163
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
164164

165165
if matches.free.is_empty() {
166-
for line in BufReader::new(stdin()).lines() {
166+
let stdin = stdin();
167+
for line in stdin.lock().lines() {
167168
for number in line.unwrap().split_whitespace() {
168169
print_factors_str(number);
169170
}

src/ln/ln.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
extern crate uucore;
1414

1515
use std::fs;
16-
use std::io::{stdin, BufRead, BufReader, Result};
16+
use std::io::{stdin, Result};
1717
#[cfg(any(unix, target_os = "redox"))]
1818
use std::os::unix::fs::symlink;
1919
#[cfg(windows)]
@@ -303,7 +303,7 @@ fn link(src: &PathBuf, dst: &PathBuf, settings: &Settings) -> Result<()> {
303303

304304
fn read_yes() -> bool {
305305
let mut s = String::new();
306-
match BufReader::new(stdin()).read_line(&mut s) {
306+
match stdin().read_line(&mut s) {
307307
Ok(_) => match s.char_indices().nth(0) {
308308
Some((_, x)) => x == 'y' || x == 'Y',
309309
_ => false,

src/mv/mv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern crate uucore;
1616

1717
use std::fs;
1818
use std::env;
19-
use std::io::{stdin, BufRead, BufReader, Result};
19+
use std::io::{stdin, Result};
2020
use std::path::{Path, PathBuf};
2121

2222
static NAME: &str = "mv";
@@ -374,7 +374,7 @@ fn rename(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<()> {
374374

375375
fn read_yes() -> bool {
376376
let mut s = String::new();
377-
match BufReader::new(stdin()).read_line(&mut s) {
377+
match stdin().read_line(&mut s) {
378378
Ok(_) => match s.chars().nth(0) {
379379
Some(x) => x == 'y' || x == 'Y',
380380
_ => false,

0 commit comments

Comments
 (0)