Update slicing syntax ([] -> [..])

This commit is contained in:
Michael Gehring 2015-02-22 12:55:30 +01:00
parent 9ae9a48387
commit 8098d172d7
4 changed files with 14 additions and 14 deletions

View file

@ -49,7 +49,7 @@ pub fn uumain(args: Vec<String>) -> 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<String>, 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<String>, 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<String>) {
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.

View file

@ -141,7 +141,7 @@ mod platform {
}
pub fn uumain(args: Vec<String>) -> i32 {
let program = &args[0][];
let program = &args[0][..];
let options = [
optflag("h", "help", "display this help and exit"),

View file

@ -38,7 +38,7 @@ struct Result {
static NAME: &'static str = "wc";
pub fn uumain(args: Vec<String>) -> 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<String>) -> 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<String>) -> 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 {

View file

@ -42,7 +42,7 @@ pub fn uumain(args: Vec<String>) -> 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<String>) -> i32 {
matches.free.connect(" ").into_cow()
};
exec(&string[]);
exec(&string[..]);
0
}