diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-01-23 18:15:06 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-01-24 13:52:22 -0800 |
| commit | ad25e208ee4978ca20123bcd2f34c16504518b8d (patch) | |
| tree | 812ad433f7aaf53000f5bb257cb57c0100f518ea /src/libstd/priority_queue.rs | |
| parent | bbbb80559c8e321dc023c48579367e2ef1349b4b (diff) | |
| download | rust-ad25e208ee4978ca20123bcd2f34c16504518b8d.tar.gz rust-ad25e208ee4978ca20123bcd2f34c16504518b8d.zip | |
librustc: Allow `&mut` to be loaned; allow `self` to be loaned; make `&mut` loanable to `&`. r=nmatsakis
Diffstat (limited to 'src/libstd/priority_queue.rs')
| -rw-r--r-- | src/libstd/priority_queue.rs | 11 |
1 files changed, 7 insertions, 4 deletions
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<T>(dst: &mut T, -src: T); + fn init<T>() -> T; } pub struct PriorityQueue <T: Ord>{ @@ -136,8 +137,9 @@ impl <T: Ord> PriorityQueue<T> { 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 <T: Ord> PriorityQueue<T> { 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; } |
