1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

Merge pull request #1307 from PaulCapron/master

Remove some useless BufReader wrappers around stdin
This commit is contained in:
Alex Lyon 2019-02-21 04:26:32 -08:00 committed by GitHub
commit 39b5760f8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 8 deletions

View file

@ -39,7 +39,7 @@ use clap::{App, Arg, ArgMatches};
use quick_error::ResultExt;
use std::collections::HashSet;
use std::fs;
use std::io::{stdin, stdout, BufRead, BufReader, Write};
use std::io::{stdin, stdout, Write};
use std::io;
use std::path::{Path, PathBuf, StripPrefixError};
use std::str::FromStr;
@ -120,7 +120,7 @@ macro_rules! prompt_yes(
print!(" [y/N]: ");
crash_if_err!(1, stdout().flush());
let mut s = String::new();
match BufReader::new(stdin()).read_line(&mut s) {
match stdin().read_line(&mut s) {
Ok(_) => match s.char_indices().nth(0) {
Some((_, x)) => x == 'y' || x == 'Y',
_ => false

View file

@ -23,7 +23,7 @@ use rand::distributions::{Distribution, Uniform};
use rand::{SeedableRng, thread_rng};
use rand::rngs::SmallRng;
use std::cmp::{max, min};
use std::io::{stdin, BufRead, BufReader};
use std::io::{stdin, BufRead};
use std::num::Wrapping;
use std::mem::swap;
@ -163,7 +163,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
let matches = new_coreopts!(SYNTAX, SUMMARY, LONG_HELP).parse(args);
if matches.free.is_empty() {
for line in BufReader::new(stdin()).lines() {
let stdin = stdin();
for line in stdin.lock().lines() {
for number in line.unwrap().split_whitespace() {
print_factors_str(number);
}

View file

@ -13,7 +13,7 @@
extern crate uucore;
use std::fs;
use std::io::{stdin, BufRead, BufReader, Result};
use std::io::{stdin, Result};
#[cfg(any(unix, target_os = "redox"))]
use std::os::unix::fs::symlink;
#[cfg(windows)]
@ -303,7 +303,7 @@ fn link(src: &PathBuf, dst: &PathBuf, settings: &Settings) -> Result<()> {
fn read_yes() -> bool {
let mut s = String::new();
match BufReader::new(stdin()).read_line(&mut s) {
match stdin().read_line(&mut s) {
Ok(_) => match s.char_indices().nth(0) {
Some((_, x)) => x == 'y' || x == 'Y',
_ => false,

View file

@ -16,7 +16,7 @@ extern crate uucore;
use std::fs;
use std::env;
use std::io::{stdin, BufRead, BufReader, Result};
use std::io::{stdin, Result};
use std::path::{Path, PathBuf};
static NAME: &str = "mv";
@ -374,7 +374,7 @@ fn rename(from: &PathBuf, to: &PathBuf, b: &Behaviour) -> Result<()> {
fn read_yes() -> bool {
let mut s = String::new();
match BufReader::new(stdin()).read_line(&mut s) {
match stdin().read_line(&mut s) {
Ok(_) => match s.chars().nth(0) {
Some(x) => x == 'y' || x == 'Y',
_ => false,