From 3bf67e3e4c306211d2beab43594e79a0caf0e379 Mon Sep 17 00:00:00 2001 From: Meltinglava Date: Fri, 8 Mar 2019 16:33:24 +0100 Subject: [PATCH] use trim_(start/end) insted of deprecated (left/right) --- src/fmt/parasplit.rs | 4 ++-- src/paste/paste.rs | 4 ++-- src/ptx/ptx.rs | 4 ++-- src/pwd/pwd.rs | 2 +- src/stdbuf/stdbuf.rs | 4 ++-- src/tsort/tsort.rs | 2 +- src/uname/uname.rs | 2 +- src/uucore/mode.rs | 2 +- src/who/who.rs | 4 ++-- tests/common/util.rs | 8 ++++---- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/fmt/parasplit.rs b/src/fmt/parasplit.rs index 42ceccf810a..499b3b04a63 100644 --- a/src/fmt/parasplit.rs +++ b/src/fmt/parasplit.rs @@ -436,7 +436,7 @@ impl<'a> ParaWords<'a> { fn create_words(&mut self) { if self.para.mail_header { // no extra spacing for mail headers; always exactly 1 space - // safe to trim_left on every line of a mail header, since the + // safe to trim_start on every line of a mail header, since the // first line is guaranteed not to have any spaces self.words.extend( self.para @@ -520,7 +520,7 @@ impl<'a> WordSplit<'a> { impl<'a> WordSplit<'a> { fn new<'b>(opts: &'b FmtOptions, string: &'b str) -> WordSplit<'b> { // wordsplits *must* start at a non-whitespace character - let trim_string = string.trim_left(); + let trim_string = string.trim_start(); WordSplit { opts, string: trim_string, diff --git a/src/paste/paste.rs b/src/paste/paste.rs index 0b5c13635b1..8ad29568b25 100644 --- a/src/paste/paste.rs +++ b/src/paste/paste.rs @@ -94,7 +94,7 @@ fn paste(filenames: Vec, serial: bool, delimiters: String) { match file.read_line(&mut line) { Ok(0) => break, Ok(_) => { - output.push_str(line.trim_right()); + output.push_str(line.trim_end()); output.push_str(&delimiters[delim_count % delimiters.len()]); } Err(e) => crash!(1, "{}", e.to_string()), @@ -118,7 +118,7 @@ fn paste(filenames: Vec, serial: bool, delimiters: String) { eof[i] = true; eof_count += 1; } - Ok(_) => output.push_str(line.trim_right()), + Ok(_) => output.push_str(line.trim_end()), Err(e) => crash!(1, "{}", e.to_string()), } } diff --git a/src/ptx/ptx.rs b/src/ptx/ptx.rs index 7ae696bc9bf..cc30242d5fa 100644 --- a/src/ptx/ptx.rs +++ b/src/ptx/ptx.rs @@ -416,7 +416,7 @@ fn format_tex_line(config: &Config, word_ref: &WordRef, line: &str, reference: & output.push_str(&format!("\\{} ", config.macro_name)); let all_before = if config.input_ref { let before = &line[0..word_ref.position]; - adjust_tex_str(before.trim().trim_left_matches(reference)) + adjust_tex_str(before.trim().trim_start_matches(reference)) } else { adjust_tex_str(&line[0..word_ref.position]) }; @@ -447,7 +447,7 @@ fn format_roff_line(config: &Config, word_ref: &WordRef, line: &str, reference: output.push_str(&format!(".{}", config.macro_name)); let all_before = if config.input_ref { let before = &line[0..word_ref.position]; - adjust_roff_str(before.trim().trim_left_matches(reference)) + adjust_roff_str(before.trim().trim_start_matches(reference)) } else { adjust_roff_str(&line[0..word_ref.position]) }; diff --git a/src/pwd/pwd.rs b/src/pwd/pwd.rs index e4658989dc4..c43fcf3869f 100644 --- a/src/pwd/pwd.rs +++ b/src/pwd/pwd.rs @@ -29,7 +29,7 @@ pub fn absolute_path(path: &Path) -> io::Result { path_buf .as_path() .to_string_lossy() - .trim_left_matches(r"\\?\"), + .trim_start_matches(r"\\?\"), ).to_path_buf(); Ok(path_buf) diff --git a/src/stdbuf/stdbuf.rs b/src/stdbuf/stdbuf.rs index 480f96908df..d0562eecb06 100644 --- a/src/stdbuf/stdbuf.rs +++ b/src/stdbuf/stdbuf.rs @@ -93,8 +93,8 @@ fn print_usage(opts: &Options) { } fn parse_size(size: &str) -> Option { - let ext = size.trim_left_matches(|c: char| c.is_digit(10)); - let num = size.trim_right_matches(|c: char| c.is_alphabetic()); + let ext = size.trim_start_matches(|c: char| c.is_digit(10)); + let num = size.trim_end_matches(|c: char| c.is_alphabetic()); let mut recovered = num.to_owned(); recovered.push_str(ext); if recovered != size { diff --git a/src/tsort/tsort.rs b/src/tsort/tsort.rs index 08c52cabe53..b6ec7fc6156 100644 --- a/src/tsort/tsort.rs +++ b/src/tsort/tsort.rs @@ -79,7 +79,7 @@ pub fn uumain(args: Vec) -> i32 { let mut line = String::new(); match reader.read_line(&mut line) { Ok(_) => { - let tokens: Vec = line.trim_right() + let tokens: Vec = line.trim_end() .split_whitespace() .map(|s| s.to_owned()) .collect(); diff --git a/src/uname/uname.rs b/src/uname/uname.rs index 05fce6366c5..7adc1b4e985 100644 --- a/src/uname/uname.rs +++ b/src/uname/uname.rs @@ -122,7 +122,7 @@ pub fn uumain(args: Vec) -> i32 { output.push_str(HOST_OS); output.push_str(" "); } - println!("{}", output.trim_right()); + println!("{}", output.trim_end()); 0 } diff --git a/src/uucore/mode.rs b/src/uucore/mode.rs index 7a08652db91..26e237a7b86 100644 --- a/src/uucore/mode.rs +++ b/src/uucore/mode.rs @@ -10,7 +10,7 @@ use std::error::Error; pub fn parse_numeric(fperm: u32, mut mode: &str) -> Result { let (op, pos) = parse_op(mode, Some('='))?; - mode = mode[pos..].trim_left_matches('0'); + mode = mode[pos..].trim_start_matches('0'); if mode.len() > 4 { Err(format!("mode is too large ({} > 7777)", mode)) } else { diff --git a/src/who/who.rs b/src/who/who.rs index 83780edbd66..2f25c970a5f 100644 --- a/src/who/who.rs +++ b/src/who/who.rs @@ -281,7 +281,7 @@ fn current_tty() -> String { if !res.is_null() { CStr::from_ptr(res as *const _) .to_string_lossy() - .trim_left_matches("/dev/") + .trim_start_matches("/dev/") .to_owned() } else { "".to_owned() @@ -510,7 +510,7 @@ impl Who { if self.include_exit { buf.push_str(&format!(" {:<12}", exit)); } - println!("{}", buf.trim_right()); + println!("{}", buf.trim_end()); } #[inline] diff --git a/tests/common/util.rs b/tests/common/util.rs index 1a0e4205eab..ae58c781a9e 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -93,8 +93,8 @@ impl CmdResult { /// stdout_only is a better choice unless stderr may or will be non-empty pub fn stdout_is>(&self, msg: T) -> Box<&CmdResult> { assert_eq!( - String::from(msg.as_ref()).trim_right(), - self.stdout.trim_right() + String::from(msg.as_ref()).trim_end(), + self.stdout.trim_end() ); Box::new(self) } @@ -110,8 +110,8 @@ impl CmdResult { /// stderr_only is a better choice unless stdout may or will be non-empty pub fn stderr_is>(&self, msg: T) -> Box<&CmdResult> { assert_eq!( - String::from(msg.as_ref()).trim_right(), - self.stderr.trim_right() + String::from(msg.as_ref()).trim_end(), + self.stderr.trim_end() ); Box::new(self) }