Skip to content

Commit 60803e5

Browse files
committed
Fix tests with the swap operator
1 parent 63c7e2f commit 60803e5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

doc/tutorial-ffi.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ wrapping `malloc` and `free`:
151151
~~~~
152152
use core::libc::{c_void, size_t, malloc, free};
153153
use core::unstable::intrinsics;
154+
use core::util;
154155
155156
// a wrapper around the handle returned by the foreign code
156157
pub struct Unique<T> {
@@ -184,7 +185,8 @@ impl<T: Owned> Drop for Unique<T> {
184185
fn finalize(&self) {
185186
unsafe {
186187
let mut x = intrinsics::init(); // dummy value to swap in
187-
x <-> *self.ptr; // moving the object out is needed to call the destructor
188+
// moving the object out is needed to call the destructor
189+
util::replace_ptr(self.ptr, x);
188190
free(self.ptr as *c_void)
189191
}
190192
}

src/test/bench/msgsend-ring-pipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ fn thread_ring(i: uint,
4343
// Send/Receive lots of messages.
4444
for uint::range(0, count) |j| {
4545
//error!("task %?, iter %?", i, j);
46-
let num_chan2 = replace(&mut num_chan, None);
47-
let num_port2 = replace(&mut num_port, None);
46+
let num_chan2 = util::replace(&mut num_chan, None);
47+
let num_port2 = util::replace(&mut num_port, None);
4848
num_chan = Some(ring::client::num(num_chan2.unwrap(), i * j));
4949
let port = num_port2.unwrap();
5050
match recv(port) {

0 commit comments

Comments
 (0)