summary refs log tree commit diff
path: root/src/libstd/os.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-06-11 13:10:37 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2013-06-12 12:21:04 +1000
commitefc71a8bdb28fba88d0cc8916b33838bf43b3a8d (patch)
treead0086d4319facd8da21583e19a952a01250bbbd /src/libstd/os.rs
parentba4a4778cc17c64c33a891a0d2565a1fb04ddffc (diff)
downloadrust-efc71a8bdb28fba88d0cc8916b33838bf43b3a8d.tar.gz
rust-efc71a8bdb28fba88d0cc8916b33838bf43b3a8d.zip
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).
Diffstat (limited to 'src/libstd/os.rs')
-rw-r--r--src/libstd/os.rs4
1 files changed, 2 insertions, 2 deletions
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)