From ad25e208ee4978ca20123bcd2f34c16504518b8d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 23 Jan 2013 18:15:06 -0800 Subject: librustc: Allow `&mut` to be loaned; allow `self` to be loaned; make `&mut` loanable to `&`. r=nmatsakis --- src/libstd/priority_queue.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/libstd/priority_queue.rs') diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index a348026f072..01b62797a8d 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -19,6 +19,7 @@ use core::vec; #[abi = "rust-intrinsic"] extern "C" mod rusti { fn move_val_init(dst: &mut T, -src: T); + fn init() -> T; } pub struct PriorityQueue { @@ -136,8 +137,9 @@ impl PriorityQueue { while pos > start { let parent = (pos - 1) >> 1; if new > self.data[parent] { - rusti::move_val_init(&mut self.data[pos], - move *addr_of(&self.data[parent])); + let mut x = rusti::init(); + x <-> self.data[parent]; + rusti::move_val_init(&mut self.data[pos], move x); pos = parent; loop } @@ -159,8 +161,9 @@ impl PriorityQueue { if right < end && !(self.data[child] > self.data[right]) { child = right; } - rusti::move_val_init(&mut self.data[pos], - move *addr_of(&self.data[child])); + let mut x = rusti::init(); + x <-> self.data[child]; + rusti::move_val_init(&mut self.data[pos], move x); pos = child; child = 2 * pos + 1; } -- cgit 1.4.1-3-g733a5