std: add str.to_c_str()

This commit is contained in:
Erick Tryzelaar
2013-08-03 14:13:34 -07:00
parent 6011f83dec
commit 08b6cb46c6
2 changed files with 27 additions and 1 deletions

View File

@@ -1948,7 +1948,7 @@ mod tests {
};
assert!((ostream as uint != 0u));
let s = ~"hello";
let mut buf = s.as_bytes_with_null().to_owned();
let mut buf = s.to_owned().to_c_str();
let len = buf.len();
do buf.as_mut_buf |b, _len| {
assert_eq!(libc::fwrite(b as *c_void, 1u as size_t,