From 8098d172d7eb0a1eb7ac8044d50d17cf27378a5a Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Sun, 22 Feb 2015 12:55:30 +0100 Subject: [PATCH] Update slicing syntax ([] -> [..]) --- src/cat/cat.rs | 8 ++++---- src/sync/sync.rs | 2 +- src/wc/wc.rs | 14 +++++++------- src/yes/yes.rs | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/cat/cat.rs b/src/cat/cat.rs index bbb6832c5..0cdb19dd9 100644 --- a/src/cat/cat.rs +++ b/src/cat/cat.rs @@ -49,7 +49,7 @@ pub fn uumain(args: Vec) -> i32 { println!(" {0} [OPTION]... [FILE]...", program); println!(""); print(&getopts::usage("Concatenate FILE(s), or standard input, to \ - standard output.", &opts)[]); + standard output.", &opts)[..]); println!(""); println!("With no FILE, or when FILE is -, read standard input."); return 0; @@ -95,7 +95,7 @@ fn write_lines(files: Vec, number: NumberingMode, squeeze_blank: bool, let mut line_counter: usize = 1; - for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[])) { + for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[..])) { let mut in_buf = [0; 1024 * 31]; let mut out_buf = [0; 1024 * 64]; @@ -162,7 +162,7 @@ fn write_bytes(files: Vec, number: NumberingMode, squeeze_blank: bool, let mut line_counter: usize = 1; - for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[])) { + for (mut reader, interactive) in files.iter().filter_map(|p| open(&p[..])) { // Flush all 1024 iterations. let mut flush_counter = range(0us, 1024); @@ -234,7 +234,7 @@ fn write_fast(files: Vec) { let mut writer = stdout_raw(); let mut in_buf = [0; 1024 * 64]; - for (mut reader, _) in files.iter().filter_map(|p| open(&p[])) { + for (mut reader, _) in files.iter().filter_map(|p| open(&p[..])) { while let Ok(n) = reader.read(&mut in_buf) { if n == 0 { break } // This interface is completely broken. diff --git a/src/sync/sync.rs b/src/sync/sync.rs index f827f7bae..8b76b30ec 100644 --- a/src/sync/sync.rs +++ b/src/sync/sync.rs @@ -141,7 +141,7 @@ mod platform { } pub fn uumain(args: Vec) -> i32 { - let program = &args[0][]; + let program = &args[0][..]; let options = [ optflag("h", "help", "display this help and exit"), diff --git a/src/wc/wc.rs b/src/wc/wc.rs index ebd8d266c..9132e15da 100644 --- a/src/wc/wc.rs +++ b/src/wc/wc.rs @@ -38,7 +38,7 @@ struct Result { static NAME: &'static str = "wc"; pub fn uumain(args: Vec) -> i32 { - let program = &args[0][]; + let program = &args[0][..]; let opts = [ getopts::optflag("c", "bytes", "print the byte counts"), getopts::optflag("m", "chars", "print the character counts"), @@ -60,7 +60,7 @@ pub fn uumain(args: Vec) -> i32 { println!("Usage:"); println!(" {0} [OPTION]... [FILE]...", program); println!(""); - print(&getopts::usage("Print newline, word and byte counts for each FILE", &opts)[]); + print(&getopts::usage("Print newline, word and byte counts for each FILE", &opts)[..]); println!(""); println!("With no FILE, or when FILE is -, read standard input."); return 0; @@ -74,10 +74,10 @@ pub fn uumain(args: Vec) -> i32 { let files = if matches.free.is_empty() { vec!["-".to_string()].into_cow() } else { - matches.free[].into_cow() + matches.free[..].into_cow() }; - match wc(&files[], &matches) { + match wc(&files[..], &matches) { Ok(()) => ( /* pass */ ), Err(e) => return e } @@ -108,7 +108,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> { let mut max_str_len: usize = 0; for path in files.iter() { - let mut reader = try!(open(&path[])); + let mut reader = try!(open(&path[..])); let mut line_count: usize = 0; let mut word_count: usize = 0; @@ -128,7 +128,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> { // try and convert the bytes to UTF-8 first let current_char_count; - match from_utf8(&raw_line[]) { + match from_utf8(&raw_line[..]) { Ok(line) => { word_count += line.words().count(); current_char_count = line.chars().count(); @@ -170,7 +170,7 @@ pub fn wc(files: &[String], matches: &Matches) -> StdResult<(), i32> { } for result in results.iter() { - print_stats(&result.filename[], result.lines, result.words, result.chars, result.bytes, result.max_line_length, matches, max_str_len); + print_stats(&result.filename[..], result.lines, result.words, result.chars, result.bytes, result.max_line_length, matches, max_str_len); } if files.len() > 1 { diff --git a/src/yes/yes.rs b/src/yes/yes.rs index 630334342..4f6bf17d4 100644 --- a/src/yes/yes.rs +++ b/src/yes/yes.rs @@ -42,7 +42,7 @@ pub fn uumain(args: Vec) -> i32 { println!("Usage:"); println!(" {0} [STRING]... [OPTION]...", program); println!(""); - print(&getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts)[]); + print(&getopts::usage("Repeatedly output a line with all specified STRING(s), or 'y'.", &opts)[..]); return 0; } if matches.opt_present("version") { @@ -55,7 +55,7 @@ pub fn uumain(args: Vec) -> i32 { matches.free.connect(" ").into_cow() }; - exec(&string[]); + exec(&string[..]); 0 }