diff options
| author | Mikhail Zabaluev <mikhail.zabaluev@gmail.com> | 2015-02-04 01:00:38 +0200 |
|---|---|---|
| committer | Mikhail Zabaluev <mikhail.zabaluev@gmail.com> | 2015-02-05 13:54:26 +0200 |
| commit | 3ac862816fc57fb6047986624d98f986cbfd40b9 (patch) | |
| tree | 3f98052301b15a4ddb142978f7c713dc06583f31 /src/libstd | |
| parent | 2bd8ec2d197809fc0f0efccf1de14419ffb17b2b (diff) | |
| download | rust-3ac862816fc57fb6047986624d98f986cbfd40b9.tar.gz rust-3ac862816fc57fb6047986624d98f986cbfd40b9.zip | |
Replace usage of slice::from_raw_buf with slice::from_raw_parts
New functions, slice::from_raw_parts and slice::from_raw_parts_mut, are added to implement the lifetime convention as agreed in RFC PR #556. The functions slice::from_raw_buf and slice::from_raw_mut_buf are left deprecated for the time being.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ffi/c_str.rs | 4 | ||||
| -rw-r--r-- | src/libstd/os.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/windows/os.rs | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 2e55c007b55..fcc4509aa94 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -162,7 +162,7 @@ impl fmt::Debug for CString { /// ``` pub unsafe fn c_str_to_bytes<'a>(raw: &'a *const libc::c_char) -> &'a [u8] { let len = libc::strlen(*raw); - slice::from_raw_buf(&*(raw as *const _ as *const *const u8), len as uint) + slice::from_raw_parts(*(raw as *const _ as *const *const u8), len as usize) } /// Interpret a C string as a byte slice with the nul terminator. @@ -171,7 +171,7 @@ pub unsafe fn c_str_to_bytes<'a>(raw: &'a *const libc::c_char) -> &'a [u8] { /// will include the nul terminator of the string. pub unsafe fn c_str_to_bytes_with_nul<'a>(raw: &'a *const libc::c_char) -> &'a [u8] { let len = libc::strlen(*raw) + 1; - slice::from_raw_buf(&*(raw as *const _ as *const *const u8), len as uint) + slice::from_raw_parts(*(raw as *const _ as *const *const u8), len as usize) } #[cfg(test)] diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 64f9e16aee4..dcdd31639d3 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -671,7 +671,7 @@ fn real_args() -> Vec<String> { // Push it onto the list. let ptr = ptr as *const u16; - let buf = slice::from_raw_buf(&ptr, len); + let buf = slice::from_raw_parts(ptr, len); let opt_s = String::from_utf16(sys::truncate_utf16_at_nul(buf)); opt_s.ok().expect("CommandLineToArgvW returned invalid UTF-16") }).collect(); diff --git a/src/libstd/sys/windows/os.rs b/src/libstd/sys/windows/os.rs index c71e2d057c3..d8e3e6981df 100644 --- a/src/libstd/sys/windows/os.rs +++ b/src/libstd/sys/windows/os.rs @@ -109,7 +109,7 @@ impl Iterator for Env { len += 1; } let p = p as *const u16; - let s = slice::from_raw_buf(&p, len as usize); + let s = slice::from_raw_parts(p, len as usize); self.cur = self.cur.offset(len + 1); let (k, v) = match s.iter().position(|&b| b == '=' as u16) { @@ -296,7 +296,7 @@ impl Iterator for Args { // Push it onto the list. let ptr = ptr as *const u16; - let buf = slice::from_raw_buf(&ptr, len as usize); + let buf = slice::from_raw_parts(ptr, len as usize); OsStringExt::from_wide(buf) }) } |
