From 9b3bfed359b2d513428b7bc7297a134bb3b2be71 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Wed, 28 May 2014 08:33:39 +0200 Subject: [PATCH] to_{strbuf,owned} -> to_string --- basename/basename.rs | 6 +++--- cat/cat.rs | 8 ++++---- comm/comm.rs | 2 +- du/du.rs | 4 ++-- env/env.rs | 10 +++++----- fold/fold.rs | 14 +++++++------- hostname/hostname.rs | 2 +- kill/kill.rs | 2 +- md5sum/md5sum.rs | 2 +- mkdir/mkdir.rs | 4 ++-- paste/paste.rs | 4 ++-- rm/rm.rs | 2 +- seq/seq.rs | 4 ++-- sleep/sleep.rs | 8 ++++---- tac/tac.rs | 6 +++--- tee/tee.rs | 6 +++--- touch/touch.rs | 28 ++++++++++++++-------------- tr/tr.rs | 2 +- truncate/truncate.rs | 2 +- uname/uname.rs | 2 +- wc/wc.rs | 6 +++--- yes/yes.rs | 2 +- 22 files changed, 63 insertions(+), 63 deletions(-) diff --git a/basename/basename.rs b/basename/basename.rs index 882c966ba..c3364ae9f 100644 --- a/basename/basename.rs +++ b/basename/basename.rs @@ -100,12 +100,12 @@ fn strip_dir(fullname: &str) -> String { fn strip_suffix(name: &str, suffix: &str) -> String { if name == suffix { - return name.into_strbuf(); + return name.into_string(); } if name.ends_with(suffix) { - return name.slice_to(name.len() - suffix.len()).into_strbuf(); + return name.slice_to(name.len() - suffix.len()).into_string(); } - return name.into_strbuf(); + return name.into_string(); } diff --git a/cat/cat.rs b/cat/cat.rs index beb5a3cd6..ca269ab8f 100644 --- a/cat/cat.rs +++ b/cat/cat.rs @@ -62,13 +62,13 @@ fn main() { if matches.opt_present("number-nonblank") { number_mode = NumberNonEmpty; } - let show_nonprint = matches.opts_present(["show-nonprinting".to_strbuf(), "show-all".to_strbuf(), "t".to_strbuf(), "e".to_strbuf()]); - let show_ends = matches.opts_present(["show-ends".to_strbuf(), "show-all".to_strbuf(), "e".to_strbuf()]); - let show_tabs = matches.opts_present(["show-tabs".to_strbuf(), "show-all".to_strbuf(), "t".to_strbuf()]); + let show_nonprint = matches.opts_present(["show-nonprinting".to_string(), "show-all".to_string(), "t".to_string(), "e".to_string()]); + let show_ends = matches.opts_present(["show-ends".to_string(), "show-all".to_string(), "e".to_string()]); + let show_tabs = matches.opts_present(["show-tabs".to_string(), "show-all".to_string(), "t".to_string()]); let squeeze_blank = matches.opt_present("squeeze-blank"); let mut files = matches.free; if files.is_empty() { - files = vec!("-".to_strbuf()); + files = vec!("-".to_string()); } exec(files, number_mode, show_nonprint, show_ends, show_tabs, squeeze_blank); diff --git a/comm/comm.rs b/comm/comm.rs index 031c8365a..43d3eaa07 100644 --- a/comm/comm.rs +++ b/comm/comm.rs @@ -25,7 +25,7 @@ fn mkdelim(col: uint, opts: &getopts::Matches) -> String { let mut s = String::new(); let delim = match opts.opt_str("output-delimiter") { Some(d) => d.clone(), - None => "\t".to_strbuf(), + None => "\t".to_string(), }; if col > 1 && !opts.opt_present("1") { diff --git a/du/du.rs b/du/du.rs index c663d401e..a27fa07ca 100644 --- a/du/du.rs +++ b/du/du.rs @@ -210,13 +210,13 @@ ers of 1000).", let options = Options { all: matches.opt_present("all"), - program_name: program.to_owned(), + program_name: program.to_string(), max_depth: max_depth, total: matches.opt_present("total"), separate_dirs: matches.opt_present("S"), }; - let strs = if matches.free.is_empty() {vec!("./".to_strbuf())} else {matches.free.clone()}; + let strs = if matches.free.is_empty() {vec!("./".to_string())} else {matches.free.clone()}; let options_arc = Arc::new(options); diff --git a/env/env.rs b/env/env.rs index c8f74eaed..946eaebcd 100644 --- a/env/env.rs +++ b/env/env.rs @@ -87,7 +87,7 @@ fn main() { } _ => { // read the program now - opts.program.push(opt.to_owned()); + opts.program.push(opt.to_string()); break; } } @@ -103,7 +103,7 @@ fn main() { match var { None => println!("{:s}: this option requires an argument: {:s}", prog, opt.as_slice()), - Some(s) => opts.unsets.push(s.to_owned()) + Some(s) => opts.unsets.push(s.to_string()) } } @@ -136,7 +136,7 @@ fn main() { match var { None => println!("{:s}: this option requires an argument: {:s}", prog, opt.as_slice()), - Some(s) => opts.unsets.push(s.to_owned()) + Some(s) => opts.unsets.push(s.to_string()) } } _ => { @@ -160,7 +160,7 @@ fn main() { } // no, its a program-like opt _ => { - opts.program.push(opt.to_owned()); + opts.program.push(opt.to_string()); break; } } @@ -171,7 +171,7 @@ fn main() { // read program arguments for opt in iter { - opts.program.push(opt.to_owned()); + opts.program.push(opt.to_string()); } let env = std::os::env(); diff --git a/fold/fold.rs b/fold/fold.rs index 5c1b63bd1..7ab19ae21 100644 --- a/fold/fold.rs +++ b/fold/fold.rs @@ -62,7 +62,7 @@ fn main() { matches.opt_str("w") } else { match obs_width { - Some(v) => Some(v.to_strbuf()), + Some(v) => Some(v.to_string()), None => None, } }; @@ -74,7 +74,7 @@ fn main() { None => 80 }; let files = if matches.free.is_empty() { - vec!("-".to_strbuf()) + vec!("-".to_string()) } else { matches.free }; @@ -88,7 +88,7 @@ fn handle_obsolete(args: &[String]) -> (Vec, Option) { while i < args.len() { if args.get(i).as_slice().char_at(0) == '-' && args.get(i).len() > 1 && args.get(i).as_slice().char_at(1).is_digit() { return (args.clone(), - Some(args.remove(i).unwrap().as_slice().slice_from(1).to_owned())); + Some(args.remove(i).unwrap().as_slice().slice_from(1).to_string())); } i += 1; } @@ -172,19 +172,19 @@ fn fold_file(file: BufferedReader, bytes: bool, spaces: bool, if spaces && i + 1 != line.len() { match slice.rfind(|ch: char| ch.is_whitespace()) { Some(m) => { - let routput = slice.slice_from(m + 1).to_owned(); + let routput = slice.slice_from(m + 1).to_string(); let ncount = routput.as_slice().chars().fold(0, |out, ch: char| out + if ch == '\t' { 8 } else { 1 }); (slice.slice_to(m + 1), routput, ncount) }, - None => (slice, "".to_owned(), 0) + None => (slice, "".to_string(), 0) } } else { - (slice, "".to_owned(), 0) + (slice, "".to_string(), 0) }; println!("{}", out); (val, ncount) }; - output = val.into_strbuf(); + output = val.into_string(); count = ncount; } } diff --git a/hostname/hostname.rs b/hostname/hostname.rs index 9aac3ca18..05929c130 100644 --- a/hostname/hostname.rs +++ b/hostname/hostname.rs @@ -92,7 +92,7 @@ fn xgethostname() -> String { let last_char = name.iter().position(|byte| *byte == 0).unwrap_or(namelen); - str::from_utf8(name.slice_to(last_char)).unwrap().to_owned() + str::from_utf8(name.slice_to(last_char)).unwrap().to_string() } fn xsethostname(name: &str) { diff --git a/kill/kill.rs b/kill/kill.rs index 5f7de6698..ac9fa2591 100644 --- a/kill/kill.rs +++ b/kill/kill.rs @@ -89,7 +89,7 @@ fn main() { }; match mode { - Kill => kill(matches.opt_str("signal").unwrap_or("9".to_strbuf()).as_slice(), matches.free), + Kill => kill(matches.opt_str("signal").unwrap_or("9".to_string()).as_slice(), matches.free), Table => table(), List => list(matches.opt_str("list")), Help => help(NAME, usage.as_slice()), diff --git a/md5sum/md5sum.rs b/md5sum/md5sum.rs index 4bd30f9ae..b368e302a 100644 --- a/md5sum/md5sum.rs +++ b/md5sum/md5sum.rs @@ -68,7 +68,7 @@ fn main() { let strict = matches.opt_present("strict"); let warn = matches.opt_present("warn") && !status; let files = if matches.free.is_empty() { - vec!("-".to_strbuf()) + vec!("-".to_string()) } else { matches.free }; diff --git a/mkdir/mkdir.rs b/mkdir/mkdir.rs index acde243e8..7f56bb69d 100644 --- a/mkdir/mkdir.rs +++ b/mkdir/mkdir.rs @@ -63,7 +63,7 @@ fn main() { // Translate a ~str in octal form to u32, default to 755 // Not tested on Windows - let mode_match = matches.opts_str(&["mode".to_strbuf()]); + let mode_match = matches.opts_str(&["mode".to_string()]); let mode: FilePermission = if mode_match.is_some() { let m = mode_match.unwrap(); let res: Option = strconv::from_str_common(m.as_slice(), 8, false, false, false, @@ -105,7 +105,7 @@ fn exec(dirs: Vec, mk_parents: bool, mode: FilePermission, verbose: bool match parent { Some(p) => { if !Path::new(p).exists() { - parent_dirs.push(p.to_strbuf()) + parent_dirs.push(p.to_string()) } }, None => () diff --git a/paste/paste.rs b/paste/paste.rs index 5dc76d9a5..e76143234 100644 --- a/paste/paste.rs +++ b/paste/paste.rs @@ -50,7 +50,7 @@ fn main() { let serial = matches.opt_present("serial"); let delimiters = match matches.opt_str("delimiters") { Some(m) => m, - None => "\t".to_strbuf() + None => "\t".to_string() }; paste(matches.free, serial, delimiters.as_slice()); } @@ -90,7 +90,7 @@ fn paste(filenames: Vec, serial: bool, delimiters: &str) { } else { let mut eof = Vec::from_elem(files.len(), false); loop { - let mut output = "".to_owned(); + let mut output = "".to_string(); let mut eof_count = 0; for (i, file) in files.mut_iter().enumerate() { if *eof.get(i) { diff --git a/rm/rm.rs b/rm/rm.rs index 8148637d2..73d072afc 100644 --- a/rm/rm.rs +++ b/rm/rm.rs @@ -133,7 +133,7 @@ fn remove(files: Vec, force: bool, interactive: InteractiveMode, one_fs: crash!(1, "{}", f.to_str()); } }; - remove(walk_dir.map(|x| x.as_str().unwrap().to_strbuf()).collect(), force, interactive, one_fs, preserve_root, recursive, dir, verbose); + remove(walk_dir.map(|x| x.as_str().unwrap().to_string()).collect(), force, interactive, one_fs, preserve_root, recursive, dir, verbose); remove_dir(&file, filename, interactive, verbose); } else if dir && (filename != "/" || !preserve_root) { remove_dir(&file, filename, interactive, verbose); diff --git a/seq/seq.rs b/seq/seq.rs index 4a05cfdb8..b44740642 100644 --- a/seq/seq.rs +++ b/seq/seq.rs @@ -83,8 +83,8 @@ fn main() { Ok(n) => n, Err(s) => { show_error!(1, "{:s}", s); return; } }; - let separator = escape_sequences(matches.opt_str("s").unwrap_or("\n".to_strbuf()).as_slice()); - let terminator = escape_sequences(matches.opt_str("t").unwrap_or(separator.to_strbuf()).as_slice()); + let separator = escape_sequences(matches.opt_str("s").unwrap_or("\n".to_string()).as_slice()); + let terminator = escape_sequences(matches.opt_str("t").unwrap_or(separator.to_string()).as_slice()); print_seq(first, step, last, separator, terminator, matches.opt_present("w")); } diff --git a/sleep/sleep.rs b/sleep/sleep.rs index af4472e80..bddae9858 100644 --- a/sleep/sleep.rs +++ b/sleep/sleep.rs @@ -67,7 +67,7 @@ fn sleep(args: Vec) { let (arg, suffix_time) = match match_suffix(arg.as_slice()) { Ok(m) => m, Err(f) => { - crash!(1, "{}", f.to_strbuf()) + crash!(1, "{}", f.to_string()) } }; let num = @@ -77,7 +77,7 @@ fn sleep(args: Vec) { match num::from_str_radix::((arg.as_slice()), 10) { Some(m) => m, None => { - crash!(1, "Invalid time interval '{}'", arg.to_strbuf()) + crash!(1, "Invalid time interval '{}'", arg.to_string()) } } }; @@ -94,11 +94,11 @@ fn match_suffix(arg: &str) -> Result<(String, int), String> { 'd' | 'D' => 60 * 60 * 24, val => { if !val.is_alphabetic() { - return Ok((arg.to_strbuf(), 1)) + return Ok((arg.to_string(), 1)) } else { return Err(format!("Invalid time interval '{}'", arg)) } } }; - Ok(((arg).slice_to((arg).len() - 1).to_owned(), result)) + Ok(((arg).slice_to((arg).len() - 1).to_string(), result)) } diff --git a/tac/tac.rs b/tac/tac.rs index adc22e35f..0256d1e54 100644 --- a/tac/tac.rs +++ b/tac/tac.rs @@ -58,10 +58,10 @@ fn main() { m } } - None => "\n".to_strbuf() + None => "\n".to_string() }; let files = if matches.free.is_empty() { - vec!("-".to_strbuf()) + vec!("-".to_string()) } else { matches.free }; @@ -81,7 +81,7 @@ fn tac(filenames: Vec, before: bool, _: bool, separator: &str) { let mut data = crash_if_err!(1, file.read_to_str()); if data.as_slice().ends_with("\n") { // removes blank line that is inserted otherwise - let mut buf = data.into_strbuf(); + let mut buf = data.into_string(); let len = buf.len(); buf.truncate(len - 1); data = buf.into_owned(); diff --git a/tee/tee.rs b/tee/tee.rs index fc13df3c5..c3358706a 100644 --- a/tee/tee.rs +++ b/tee/tee.rs @@ -47,7 +47,7 @@ fn options(args: &[String]) -> Result { optflag("V", "version", "output version information and exit"), ]; - let args: Vec = args.iter().map(|x| x.to_strbuf()).collect(); + let args: Vec = args.iter().map(|x| x.to_string()).collect(); getopts(args.tail(), opts).map_err(|e| e.to_err_msg()).and_then(|m| { let version = format!("{} {}", NAME, VERSION); @@ -58,12 +58,12 @@ fn options(args: &[String]) -> Result { let help = format!("{}\n\nUsage:\n {} {}\n\n{}\n{}", version, program, arguments, usage(brief, opts), comment); - let names = m.free.clone().move_iter().collect::>().append_one("-".to_strbuf()); + let names = m.free.clone().move_iter().collect::>().append_one("-".to_string()); let to_print = if m.opt_present("help") { Some(help) } else if m.opt_present("version") { Some(version) } else { None }; Ok(Options { - program: program.to_strbuf(), + program: program.to_string(), append: m.opt_present("append"), ignore_interrupts: m.opt_present("ignore-interrupts"), print_and_exit: to_print, diff --git a/touch/touch.rs b/touch/touch.rs index 920a58424..9c69f6665 100644 --- a/touch/touch.rs +++ b/touch/touch.rs @@ -60,18 +60,18 @@ fn main() { return; } - if matches.opt_present("date") && matches.opts_present(["reference".to_owned(), "t".to_owned()]) || - matches.opt_present("reference") && matches.opts_present(["date".to_owned(), "t".to_owned()]) || - matches.opt_present("t") && matches.opts_present(["date".to_owned(), "reference".to_owned()]) { + if matches.opt_present("date") && matches.opts_present(["reference".to_string(), "t".to_string()]) || + matches.opt_present("reference") && matches.opts_present(["date".to_string(), "t".to_string()]) || + matches.opt_present("t") && matches.opts_present(["date".to_string(), "reference".to_string()]) { fail!("Invalid options: cannot specify reference time from more than one source"); } let (mut atime, mut mtime) = if matches.opt_present("reference") { - let path = Path::new(matches.opt_str("reference").unwrap().to_owned()); + let path = Path::new(matches.opt_str("reference").unwrap().to_string()); let stat = stat(&path, !matches.opt_present("no-dereference")); (stat.accessed, stat.modified) - } else if matches.opts_present(["date".to_owned(), "t".to_owned()]) { + } else if matches.opts_present(["date".to_string(), "t".to_string()]) { let timestamp = if matches.opt_present("date") { parse_date(matches.opt_str("date").unwrap().as_slice()) } else { @@ -85,11 +85,11 @@ fn main() { }; for filename in matches.free.iter() { - let path = Path::new(filename.to_owned()); + let path = Path::new(filename.to_string()); if !path.exists() { // no-dereference included here for compatibility - if matches.opts_present(["no-create".to_owned(), "no-dereference".to_owned()]) { + if matches.opts_present(["no-create".to_string(), "no-dereference".to_string()]) { continue; } @@ -99,27 +99,27 @@ fn main() { }; // Minor optimization: if no reference time was specified, we're done. - if !matches.opts_present(["date".to_owned(), "reference".to_owned(), "t".to_owned()]) { + if !matches.opts_present(["date".to_string(), "reference".to_string(), "t".to_string()]) { continue; } } // If changing "only" atime or mtime, grab the existing value of the other. // Note that "-a" and "-m" may be passed together; this is not an xor. - if matches.opts_present(["a".to_owned(), "m".to_owned(), "time".to_owned()]) { + if matches.opts_present(["a".to_string(), "m".to_string(), "time".to_string()]) { let stat = stat(&path, !matches.opt_present("no-dereference")); let time = matches.opt_strs("time"); if !(matches.opt_present("a") || - time.contains(&"access".to_strbuf()) || - time.contains(&"atime".to_strbuf()) || - time.contains(&"use".to_strbuf())) { + time.contains(&"access".to_string()) || + time.contains(&"atime".to_string()) || + time.contains(&"use".to_string())) { atime = stat.accessed; } if !(matches.opt_present("m") || - time.contains(&"modify".to_strbuf()) || - time.contains(&"mtime".to_strbuf())) { + time.contains(&"modify".to_string()) || + time.contains(&"mtime".to_string())) { mtime = stat.modified; } } diff --git a/tr/tr.rs b/tr/tr.rs index 283c44ae1..0212bccf0 100644 --- a/tr/tr.rs +++ b/tr/tr.rs @@ -181,7 +181,7 @@ pub fn main() { } let dflag = matches.opt_present("d"); - let cflag = matches.opts_present(["c".to_strbuf(), "C".to_strbuf()]); + let cflag = matches.opts_present(["c".to_string(), "C".to_string()]); let sets = matches.free; if cflag && !dflag { diff --git a/truncate/truncate.rs b/truncate/truncate.rs index 348c83dca..30feac64f 100644 --- a/truncate/truncate.rs +++ b/truncate/truncate.rs @@ -177,7 +177,7 @@ fn parse_size(size: &str) -> (u64, TruncateMode) { } } slice - }.to_owned().into_bytes(); + }.to_string().into_bytes(); let mut number = match u64::parse_bytes(bytes.as_slice(), 10) { Some(num) => num, None => { diff --git a/uname/uname.rs b/uname/uname.rs index df162239b..a438d1a32 100644 --- a/uname/uname.rs +++ b/uname/uname.rs @@ -80,7 +80,7 @@ fn main() { let uname = unsafe { getuname() }; let mut output = String::new(); if matches.opt_present("sysname") || matches.opt_present("all") - || !matches.opts_present(["nodename".to_strbuf(), "release".to_strbuf(), "version".to_strbuf(), "machine".to_strbuf()]) { + || !matches.opts_present(["nodename".to_string(), "release".to_string(), "version".to_string(), "machine".to_string()]) { output.push_str(uname.sysname.as_slice()); output.push_str(" "); } diff --git a/wc/wc.rs b/wc/wc.rs index f5f4b9c86..1db8730ec 100644 --- a/wc/wc.rs +++ b/wc/wc.rs @@ -70,7 +70,7 @@ fn main() { let mut files = matches.free.clone(); if files.is_empty() { - files = vec!("-".to_strbuf()); + files = vec!("-".to_string()); } wc(files, &matches); @@ -98,7 +98,7 @@ pub fn wc(files: Vec, matches: &Matches) { let mut max_str_len: uint = 0; for path in files.iter() { - let mut reader = match open(path.to_owned()) { + let mut reader = match open(path.to_string()) { Some(f) => f, None => { continue } }; @@ -155,7 +155,7 @@ pub fn wc(files: Vec, matches: &Matches) { } results.push(Result { - filename: path.to_strbuf(), + filename: path.to_string(), bytes: byte_count, chars: char_count, lines: line_count, diff --git a/yes/yes.rs b/yes/yes.rs index eedc24bdd..f846d9892 100644 --- a/yes/yes.rs +++ b/yes/yes.rs @@ -50,7 +50,7 @@ fn main() { println!("yes 1.0.0"); return; } - let mut string = "y".to_owned(); + let mut string = "y".to_string(); if !matches.free.is_empty() { string = matches.free.connect(" "); }