diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-04-17 15:59:07 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-04-18 10:57:10 -0700 |
| commit | 675b82657e7d9fd4c824ff3c6dbead1edd1ab515 (patch) | |
| tree | ac2ffc0405647555976c3b6b90e98a4e9398eb11 /src/libnative | |
| parent | 7d3b0bf3912fabf52fdd6926900e578e55af1b49 (diff) | |
| download | rust-675b82657e7d9fd4c824ff3c6dbead1edd1ab515.tar.gz rust-675b82657e7d9fd4c824ff3c6dbead1edd1ab515.zip | |
Update the rest of the compiler with ~[T] changes
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/addrinfo.rs | 4 | ||||
| -rw-r--r-- | src/libnative/io/file_unix.rs | 3 | ||||
| -rw-r--r-- | src/libnative/io/process.rs | 16 |
3 files changed, 9 insertions, 14 deletions
diff --git a/src/libnative/io/addrinfo.rs b/src/libnative/io/addrinfo.rs index 5b872a2dbc5..71944202205 100644 --- a/src/libnative/io/addrinfo.rs +++ b/src/libnative/io/addrinfo.rs @@ -57,7 +57,7 @@ impl GetAddrInfoRequest { } // Collect all the results we found - let mut addrs = ~[]; + let mut addrs = Vec::new(); let mut rp = res; while rp.is_not_null() { unsafe { @@ -80,7 +80,7 @@ impl GetAddrInfoRequest { unsafe { freeaddrinfo(res); } - Ok(addrs) + Ok(addrs.move_iter().collect()) } } diff --git a/src/libnative/io/file_unix.rs b/src/libnative/io/file_unix.rs index 5446ab2950e..d97a0430fea 100644 --- a/src/libnative/io/file_unix.rs +++ b/src/libnative/io/file_unix.rs @@ -18,7 +18,6 @@ use libc::{c_int, c_void}; use libc; use std::mem; use std::rt::rtio; -use std::slice; use io::{IoResult, retry, keep_going}; @@ -416,7 +415,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> { if len == -1 { len = 1024; // FIXME: read PATH_MAX from C ffi? } - let mut buf = slice::with_capacity::<u8>(len as uint); + let mut buf: Vec<u8> = Vec::with_capacity(len as uint); match retry(|| unsafe { libc::readlink(p, buf.as_ptr() as *mut libc::c_char, len as libc::size_t) as libc::c_int diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index e3bb938995b..385287d998e 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -74,7 +74,7 @@ impl Process { return Err(super::unimpl()); } - fn get_io(io: p::StdioContainer, ret: &mut ~[Option<file::FileDesc>]) + fn get_io(io: p::StdioContainer, ret: &mut Vec<Option<file::FileDesc>>) -> (Option<os::Pipe>, c_int) { match io { @@ -93,7 +93,7 @@ impl Process { } } - let mut ret_io = ~[]; + let mut ret_io = Vec::new(); let (in_pipe, in_fd) = get_io(config.stdin, &mut ret_io); let (out_pipe, out_fd) = get_io(config.stdout, &mut ret_io); let (err_pipe, err_fd) = get_io(config.stderr, &mut ret_io); @@ -117,7 +117,7 @@ impl Process { exit_code: None, exit_signal: None, }, - ret_io)) + ret_io.move_iter().collect())) } Err(e) => Err(e) } @@ -641,12 +641,10 @@ fn spawn_process_os(config: p::ProcessConfig, #[cfg(unix)] fn with_argv<T>(prog: &str, args: &[~str], cb: proc(**libc::c_char) -> T) -> T { - use std::slice; - // We can't directly convert `str`s into `*char`s, as someone needs to hold // a reference to the intermediary byte buffers. So first build an array to // hold all the ~[u8] byte strings. - let mut tmps = slice::with_capacity(args.len() + 1); + let mut tmps = Vec::with_capacity(args.len() + 1); tmps.push(prog.to_c_str()); @@ -667,14 +665,12 @@ fn with_argv<T>(prog: &str, args: &[~str], cb: proc(**libc::c_char) -> T) -> T { #[cfg(unix)] fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: proc(*c_void) -> T) -> T { - use std::slice; - // On posixy systems we can pass a char** for envp, which is a // null-terminated array of "k=v\n" strings. Like `with_argv`, we have to // have a temporary buffer to hold the intermediary `~[u8]` byte strings. match env { Some(env) => { - let mut tmps = slice::with_capacity(env.len()); + let mut tmps = Vec::with_capacity(env.len()); for pair in env.iter() { let kv = format!("{}={}", *pair.ref0(), *pair.ref1()); @@ -700,7 +696,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*mut c_void| -> T) -> T { // \0 to terminate. match env { Some(env) => { - let mut blk = ~[]; + let mut blk = Vec::new(); for pair in env.iter() { let kv = format!("{}={}", *pair.ref0(), *pair.ref1()); |
