From efc71a8bdb28fba88d0cc8916b33838bf43b3a8d Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Tue, 11 Jun 2013 13:10:37 +1000 Subject: std: unify the str -> [u8] functions as 3 methods: .as_bytes() and .as_bytes_with_null[_consume](). The first acts on &str and is not nul-terminated, the last two act on strings that are always null terminated (&'static str, ~str and @str). --- src/libstd/os.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd/os.rs') diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 66993fb9099..044b305a0dd 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -1448,9 +1448,9 @@ mod tests { use rand::RngUtil; use rand; use run; - use str; use str::StrSlice; use vec; + use vec::CopyableVector; use libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR}; @@ -1684,7 +1684,7 @@ mod tests { }; assert!((ostream as uint != 0u)); let s = ~"hello"; - let mut buf = str::to_bytes(s) + [0 as u8]; + let mut buf = s.as_bytes_with_null().to_owned(); do vec::as_mut_buf(buf) |b, _len| { assert!((libc::fwrite(b as *c_void, 1u as size_t, (s.len() + 1u) as size_t, ostream) -- cgit 1.4.1-3-g733a5