1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

growable ~[T] -> Vec<T>

This commit is contained in:
Michael Gehring 2014-05-16 11:14:28 +02:00
parent bf26ea12b2
commit b1983536e1
3 changed files with 6 additions and 6 deletions

View file

@ -96,7 +96,7 @@ fn xgethostname() -> ~str {
}
fn xsethostname(name: &~str) {
let vec_name: ~[libc::c_char] = name.bytes().map(|c| c as i8).collect();
let vec_name: Vec<libc::c_char> = name.bytes().map(|c| c as i8).collect();
let err = unsafe {
sethostname (vec_name.as_ptr(), vec_name.len() as i32)

View file

@ -57,7 +57,7 @@ fn main() {
}
fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) {
let mut files: ~[io::BufferedReader<Box<Reader>>] = filenames.move_iter().map(|name|
let mut files: Vec<io::BufferedReader<Box<Reader>>> = filenames.move_iter().map(|name|
io::BufferedReader::new(
if name == "-".to_owned() {
box io::stdio::stdin_raw() as Box<Reader>
@ -66,14 +66,14 @@ fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) {
}
)
).collect();
let delimiters: ~[~str] = delimiters.chars().map(|x| x.to_str()).collect();
let delimiters: Vec<~str> = delimiters.chars().map(|x| x.to_str()).collect();
let mut delim_count = 0;
if serial {
for file in files.mut_iter() {
let mut output = "".to_owned();
loop {
output = output + match file.read_line() {
Ok(line) => line.trim_right() + delimiters[delim_count % delimiters.len()],
Ok(line) => line.trim_right() + delimiters.get(delim_count % delimiters.len()).clone(),
Err(f) => if f.kind == io::EndOfFile {
break
} else {
@ -103,7 +103,7 @@ fn paste(filenames: Vec<~str>, serial: bool, delimiters: ~str) {
}
}
}
output = output + delimiters[delim_count % delimiters.len()];
output = output + delimiters.get(delim_count % delimiters.len()).clone();
delim_count += 1;
}
if files.len() == eof_count {

View file

@ -86,7 +86,7 @@ fn tac(filenames: Vec<~str>, before: bool, _: bool, separator: ~str) {
buf.truncate(len - 1);
data = buf.into_owned();
}
let split_vec: ~[&str] = data.split_str(separator).collect();
let split_vec: Vec<&str> = data.split_str(separator).collect();
let rev: ~str = split_vec.iter().rev().fold("".to_owned(), |a, &b|
a + if before {
separator + b