about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--doc/tutorial-ffi.md4
-rw-r--r--src/test/bench/msgsend-ring-pipes.rs4
2 files changed, 5 insertions, 3 deletions
diff --git a/doc/tutorial-ffi.md b/doc/tutorial-ffi.md
index 2a3d8dc1481..d8367fbdc2d 100644
--- a/doc/tutorial-ffi.md
+++ b/doc/tutorial-ffi.md
@@ -151,6 +151,7 @@ wrapping `malloc` and `free`:
 ~~~~
 use core::libc::{c_void, size_t, malloc, free};
 use core::unstable::intrinsics;
+use core::util;
 
 // a wrapper around the handle returned by the foreign code
 pub struct Unique<T> {
@@ -184,7 +185,8 @@ impl<T: Owned> Drop for Unique<T> {
     fn finalize(&self) {
         unsafe {
             let mut x = intrinsics::init(); // dummy value to swap in
-            x <-> *self.ptr; // moving the object out is needed to call the destructor
+            // moving the object out is needed to call the destructor
+            util::replace_ptr(self.ptr, x);
             free(self.ptr as *c_void)
         }
     }
diff --git a/src/test/bench/msgsend-ring-pipes.rs b/src/test/bench/msgsend-ring-pipes.rs
index f5191914679..f698b2c3c11 100644
--- a/src/test/bench/msgsend-ring-pipes.rs
+++ b/src/test/bench/msgsend-ring-pipes.rs
@@ -43,8 +43,8 @@ fn thread_ring(i: uint,
     // Send/Receive lots of messages.
     for uint::range(0, count) |j| {
         //error!("task %?, iter %?", i, j);
-        let num_chan2 = replace(&mut num_chan, None);
-        let num_port2 = replace(&mut num_port, None);
+        let num_chan2 = util::replace(&mut num_chan, None);
+        let num_port2 = util::replace(&mut num_port, None);
         num_chan = Some(ring::client::num(num_chan2.unwrap(), i * j));
         let port = num_port2.unwrap();
         match recv(port) {