From 7a06ae081d78d03e87c92d384c7a3230799061f0 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Fri, 9 May 2014 02:12:57 +0200 Subject: [PATCH] Update to box/Box syntax. --- base64/base64.rs | 6 +++--- cat/cat.rs | 6 +++--- env/env.rs | 2 +- fold/fold.rs | 4 ++-- md5sum/md5sum.rs | 4 ++-- paste/paste.rs | 6 +++--- tac/tac.rs | 4 ++-- tee/tee.rs | 26 +++++++++++++------------- wc/wc.rs | 6 +++--- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/base64/base64.rs b/base64/base64.rs index 6e7c53524..14dc03e1a 100644 --- a/base64/base64.rs +++ b/base64/base64.rs @@ -37,7 +37,7 @@ mod util; static NAME: &'static str = "base64"; fn main() { - let args = ~os::args(); + let args = box os::args(); let opts = ~[ optflag("d", "decode", "decode data"), optflag("i", "ignore-garbage", "when decoding, ignore non-alphabetic characters"), @@ -78,10 +78,10 @@ fn main() { None => 76 }; let mut input = if matches.free.is_empty() || matches.free.get(0).as_slice() == "-" { - ~stdin() as ~Reader + box stdin() as Box } else { let path = Path::new(matches.free.get(0).clone()); - ~File::open(&path) as ~Reader + box File::open(&path) as Box }; match mode { diff --git a/cat/cat.rs b/cat/cat.rs index fa008b427..81260e774 100644 --- a/cat/cat.rs +++ b/cat/cat.rs @@ -175,13 +175,13 @@ pub fn exec(files: Vec<~str>, number: NumberingMode, show_nonprint: bool, show_e } } -fn open(path: ~str) -> Option<~Reader> { +fn open(path: ~str) -> Option> { if "-" == path { - return Some(~stdin_raw() as ~Reader); + return Some(box stdin_raw() as Box); } match File::open(&std::path::Path::new(path.as_slice())) { - Ok(fd) => return Some(~fd as ~Reader), + Ok(fd) => return Some(box fd as Box), Err(e) => fail!("cat: {0:s}: {1:s}", path, e.to_str()) } } diff --git a/env/env.rs b/env/env.rs index 9c463c74d..6df1150d8 100644 --- a/env/env.rs +++ b/env/env.rs @@ -56,7 +56,7 @@ fn main() { let prog = args[0].as_slice(); // to handle arguments the same way than GNU env, we can't use getopts - let mut opts = ~options { + let mut opts = box options { ignore_env: false, null: false, unsets: vec!(), diff --git a/fold/fold.rs b/fold/fold.rs index 9d106df30..cfeddb150 100644 --- a/fold/fold.rs +++ b/fold/fold.rs @@ -98,9 +98,9 @@ fn fold(filenames: Vec<~str>, bytes: bool, spaces: bool, width: uint) { let filename: &str = *filename; let buffer = BufferedReader::new( if filename == "-".to_owned() { - ~io::stdio::stdin_raw() as ~Reader + box io::stdio::stdin_raw() as Box } else { - ~safe_unwrap!(File::open(&Path::new(filename))) as ~Reader + box safe_unwrap!(File::open(&Path::new(filename))) as Box } ); fold_file(buffer, bytes, spaces, width); diff --git a/md5sum/md5sum.rs b/md5sum/md5sum.rs index 89abab02d..687c8116f 100644 --- a/md5sum/md5sum.rs +++ b/md5sum/md5sum.rs @@ -85,9 +85,9 @@ fn md5sum(files: Vec<~str>, binary: bool, check: bool, tag: bool, status: bool, let filename: &str = *filename; let mut file = BufferedReader::new( if filename == "-".to_owned() { - ~stdin_raw() as ~Reader + box stdin_raw() as Box } else { - ~safe_unwrap!(File::open(&Path::new(filename))) as ~Reader + box safe_unwrap!(File::open(&Path::new(filename))) as Box } ); if check { diff --git a/paste/paste.rs b/paste/paste.rs index 549c5abc5..921e7df3f 100644 --- a/paste/paste.rs +++ b/paste/paste.rs @@ -57,12 +57,12 @@ fn main() { } fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) { - let mut files: ~[io::BufferedReader<~Reader>] = filenames.move_iter().map(|name| + let mut files: ~[io::BufferedReader>] = filenames.move_iter().map(|name| io::BufferedReader::new( if name == "-".to_owned() { - ~io::stdio::stdin_raw() as ~Reader + box io::stdio::stdin_raw() as Box } else { - ~crash_if_err!(1, io::File::open(&Path::new(name))) as ~Reader + box crash_if_err!(1, io::File::open(&Path::new(name))) as Box } ) ).collect(); diff --git a/tac/tac.rs b/tac/tac.rs index 5f21de09b..cd06a678d 100644 --- a/tac/tac.rs +++ b/tac/tac.rs @@ -73,9 +73,9 @@ fn tac(filenames: Vec<~str>, before: bool, _: bool, separator: ~str) { for filename in filenames.move_iter() { let mut file = io::BufferedReader::new( if filename == "-".to_owned() { - ~io::stdio::stdin_raw() as ~Reader + box io::stdio::stdin_raw() as Box } else { - ~crash_if_err!(1, io::File::open(&Path::new(filename))) as ~Reader + box crash_if_err!(1, io::File::open(&Path::new(filename))) as Box } ); let mut data = crash_if_err!(1, file.read_to_str()); diff --git a/tee/tee.rs b/tee/tee.rs index a580fc89f..36459aceb 100644 --- a/tee/tee.rs +++ b/tee/tee.rs @@ -36,7 +36,7 @@ struct Options { append: bool, ignore_interrupts: bool, print_and_exit: Option<~str>, - files: ~Vec + files: Box> } fn options(args: &[~str]) -> Result { @@ -66,7 +66,7 @@ fn options(args: &[~str]) -> Result { append: m.opt_present("append"), ignore_interrupts: m.opt_present("ignore-interrupts"), print_and_exit: to_print, - files: ~names.iter().map(|name| Path::new(name.clone())).collect() + files: box names.iter().map(|name| Path::new(name.clone())).collect() }) }).map_err(|message| warn(message)) } @@ -81,7 +81,7 @@ fn exec(options: Options) -> Result<(), ()> { fn tee(options: Options) -> Result<(), ()> { let writers = options.files.iter().map(|path| open(path, options.append)).collect(); let output = &mut MultiWriter::new(writers); - let input = &mut NamedReader { inner: ~stdin() as ~Reader }; + let input = &mut NamedReader { inner: box stdin() as Box }; if copy(input, output).is_err() || output.flush().is_err() { Err(()) } else { @@ -89,22 +89,22 @@ fn tee(options: Options) -> Result<(), ()> { } } -fn open(path: &Path, append: bool) -> ~Writer { +fn open(path: &Path, append: bool) -> Box { let inner = if *path == Path::new("-") { - ~stdout() as ~Writer + box stdout() as Box } else { let mode = if append { Append } else { Truncate }; match File::open_mode(path, mode, Write) { - Ok(file) => ~file as ~Writer, - Err(_) => ~NullWriter as ~Writer + Ok(file) => box file as Box, + Err(_) => box NullWriter as Box } }; - ~NamedWriter { inner: inner, path: ~path.clone() } as ~Writer + box NamedWriter { inner: inner, path: box path.clone() } as Box } struct NamedWriter { - inner: ~Writer, - path: ~Path + inner: Box, + path: Box } impl Writer for NamedWriter { @@ -112,7 +112,7 @@ impl Writer for NamedWriter { with_path(self.path.clone(), || { let val = self.inner.write(buf); if val.is_err() { - self.inner = ~NullWriter as ~Writer; + self.inner = box NullWriter as Box; } val }) @@ -122,7 +122,7 @@ impl Writer for NamedWriter { with_path(self.path.clone(), || { let val = self.inner.flush(); if val.is_err() { - self.inner = ~NullWriter as ~Writer; + self.inner = box NullWriter as Box; } val }) @@ -130,7 +130,7 @@ impl Writer for NamedWriter { } struct NamedReader { - inner: ~Reader + inner: Box } impl Reader for NamedReader { diff --git a/wc/wc.rs b/wc/wc.rs index 057509905..fc6ee9ac1 100644 --- a/wc/wc.rs +++ b/wc/wc.rs @@ -222,15 +222,15 @@ fn print_stats(filename: &~str, line_count: uint, word_count: uint, char_count: } } -fn open(path: ~str) -> Option> { +fn open(path: ~str) -> Option>> { if "-" == path { - let reader = ~stdin() as ~Reader; + let reader = box stdin() as Box; return Some(BufferedReader::new(reader)); } match File::open(&std::path::Path::new(path.as_slice())) { Ok(fd) => { - let reader = ~fd as ~Reader; + let reader = box fd as Box; return Some(BufferedReader::new(reader)); }, Err(e) => {