]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/rename-directory.rs
cleanup: s/impl Copy/#[derive(Copy)]/g
[rust.git] / src / test / run-pass / rename-directory.rs
index c7aa405b513e465bb6404d80d57df928edb5e95b..d610bf09edb958b0503c7795b95f6011cd1a1b18 100644 (file)
@@ -13,8 +13,8 @@
 
 extern crate libc;
 
+use std::ffi::CString;
 use std::io::TempDir;
-use std::c_str::ToCStr;
 use std::io::fs::PathExtensions;
 use std::io::fs;
 use std::io;
@@ -31,20 +31,17 @@ fn rename_directory() {
         let test_file = &old_path.join("temp.txt");
 
         /* Write the temp input file */
-        let ostream = test_file.with_c_str(|fromp| {
-            "w+b".with_c_str(|modebuf| {
-                libc::fopen(fromp, modebuf)
-            })
-        });
+        let fromp = CString::from_slice(test_file.as_vec());
+        let modebuf = CString::from_slice(b"w+b");
+        let ostream = libc::fopen(fromp.as_ptr(), modebuf.as_ptr());
         assert!((ostream as uint != 0u));
         let s = "hello".to_string();
-        "hello".with_c_str(|buf| {
-            let write_len = libc::fwrite(buf as *const libc::c_void,
-                                         1u as libc::size_t,
-                                         (s.len() + 1u) as libc::size_t,
-                                         ostream);
-            assert_eq!(write_len, (s.len() + 1) as libc::size_t)
-        });
+        let buf = CString::from_slice(b"hello");
+        let write_len = libc::fwrite(buf.as_ptr() as *mut _,
+                                     1u as libc::size_t,
+                                     (s.len() + 1u) as libc::size_t,
+                                     ostream);
+        assert_eq!(write_len, (s.len() + 1) as libc::size_t);
         assert_eq!(libc::fclose(ostream), (0u as libc::c_int));
 
         let new_path = tmpdir.join_many(&["quux", "blat"]);