std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut [].

This commit is contained in:
Huon Wilson 2013-12-15 23:35:12 +11:00
parent f53292f7ee
commit 164f7a290e
22 changed files with 115 additions and 113 deletions

View file

@ -20,7 +20,6 @@ use std::io;
use std::rt::local::Local;
use std::rt::rtio;
use std::rt::sched::{Scheduler, SchedHandle};
use std::vec;
use super::{Loop, UvError, uv_error_to_io_error, wait_until_woken_after};
use uvio::HomingIO;
@ -78,7 +77,7 @@ impl FsRequest {
{
execute_nop(|req, cb| unsafe {
uvll::uv_fs_write(loop_.handle, req,
fd, vec::raw::to_ptr(buf) as *c_void,
fd, buf.as_ptr() as *c_void,
buf.len() as size_t, offset, cb)
})
}
@ -88,7 +87,7 @@ impl FsRequest {
{
execute(|req, cb| unsafe {
uvll::uv_fs_read(loop_.handle, req,
fd, vec::raw::to_ptr(buf) as *c_void,
fd, buf.as_ptr() as *c_void,
buf.len() as size_t, offset, cb)
}).map(|req| {
req.get_result() as int

View file

@ -60,7 +60,6 @@ use std::str::raw::from_c_str;
use std::str;
use std::task;
use std::unstable::finally::Finally;
use std::vec;
use std::io::IoError;
@ -388,7 +387,7 @@ pub fn empty_buf() -> Buf {
/// Borrow a slice to a Buf
pub fn slice_to_uv_buf(v: &[u8]) -> Buf {
let data = vec::raw::to_ptr(v);
let data = v.as_ptr();
uvll::uv_buf_t { base: data, len: v.len() as uvll::uv_buf_len_t }
}

View file

@ -62,7 +62,7 @@ pub fn sockaddr_to_socket_addr(addr: *sockaddr) -> SocketAddr {
// apparently there's an off-by-one in libuv?
let ip_size = ip_size + 1;
let buf = vec::from_elem(ip_size + 1 /*null terminated*/, 0u8);
let buf_ptr = vec::raw::to_ptr(buf);
let buf_ptr = buf.as_ptr();
let ret = if uvll::rust_is_ipv4_sockaddr(addr) == 1 {
uvll::uv_ip4_name(addr, buf_ptr as *c_char, ip_size as size_t)
} else {

View file

@ -33,7 +33,6 @@ use std::libc::{size_t, c_int, c_uint, c_void, c_char, c_double};
use std::libc::ssize_t;
use std::libc::{malloc, free};
use std::libc;
use std::vec;
#[cfg(test)]
use std::libc::uintptr_t;
@ -419,7 +418,7 @@ pub unsafe fn uv_write(req: *uv_write_t,
cb: uv_write_cb) -> c_int;
}
let buf_ptr = vec::raw::to_ptr(buf_in);
let buf_ptr = buf_in.as_ptr();
let buf_cnt = buf_in.len() as i32;
return uv_write(req, stream, buf_ptr, buf_cnt, cb);
}
@ -435,7 +434,7 @@ pub unsafe fn uv_udp_send(req: *uv_udp_send_t,
cb: uv_udp_send_cb) -> c_int;
}
let buf_ptr = vec::raw::to_ptr(buf_in);
let buf_ptr = buf_in.as_ptr();
let buf_cnt = buf_in.len() as i32;
return uv_udp_send(req, handle, buf_ptr, buf_cnt, addr, cb);
}