@@ -280,7 +280,6 @@ pub struct BinaryHeap<
280280 data : Vec < T , A > ,
281281}
282282
283- // XXX: PeekMut<A>
284283/// Structure wrapping a mutable reference to the greatest item on a
285284/// `BinaryHeap`.
286285///
@@ -289,8 +288,12 @@ pub struct BinaryHeap<
289288///
290289/// [`peek_mut`]: BinaryHeap::peek_mut
291290#[ stable( feature = "binary_heap_peek_mut" , since = "1.12.0" ) ]
292- pub struct PeekMut < ' a , T : ' a + Ord > {
293- heap : & ' a mut BinaryHeap < T > ,
291+ pub struct PeekMut <
292+ ' a ,
293+ T : ' a + Ord ,
294+ #[ unstable( feature = "allocator_api" , issue = "32838" ) ] A : Allocator = Global ,
295+ > {
296+ heap : & ' a mut BinaryHeap < T , A > ,
294297 // If a set_len + sift_down are required, this is Some. If a &mut T has not
295298 // yet been exposed to peek_mut()'s caller, it's None.
296299 original_len : Option < NonZeroUsize > ,
@@ -359,11 +362,10 @@ impl<'a, T: Ord, A: Allocator + 'a> DerefMut for PeekMut<'a, T, A> {
359362 }
360363}
361364
362- // XXX: PeekMut<A>
363365impl < ' a , T : Ord , A : Allocator + ' a > PeekMut < ' a , T , A > {
364366 /// Removes the peeked value from the heap and returns it.
365367 #[ stable( feature = "binary_heap_peek_mut_pop" , since = "1.18.0" ) ]
366- pub fn pop ( mut this : PeekMut < ' a , T > ) -> T {
368+ pub fn pop ( mut this : PeekMut < ' a , T , A > ) -> T {
367369 if let Some ( original_len) = this. original_len . take ( ) {
368370 // SAFETY: This is how many elements were in the Vec at the time of
369371 // the BinaryHeap::peek_mut call.
@@ -404,18 +406,21 @@ impl<T: fmt::Debug, A: Allocator> fmt::Debug for BinaryHeap<T, A> {
404406 }
405407}
406408
407- struct RebuildOnDrop < ' a , T : Ord > {
408- heap : & ' a mut BinaryHeap < T > ,
409+ struct RebuildOnDrop <
410+ ' a ,
411+ T : Ord ,
412+ #[ unstable( feature = "allocator_api" , issue = "32838" ) ] A : Allocator = Global ,
413+ > {
414+ heap : & ' a mut BinaryHeap < T , A > ,
409415 rebuild_from : usize ,
410416}
411417
412- impl < ' a , T : Ord > Drop for RebuildOnDrop < ' a , T > {
418+ impl < ' a , T : Ord , A : Allocator > Drop for RebuildOnDrop < ' a , T , A > {
413419 fn drop ( & mut self ) {
414420 self . heap . rebuild_tail ( self . rebuild_from ) ;
415421 }
416422}
417423
418- // XXX: BinaryHeap<T, A>
419424impl < T : Ord > BinaryHeap < T > {
420425 /// Creates an empty `BinaryHeap` as a max-heap.
421426 ///
@@ -501,7 +506,6 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
501506 BinaryHeap { data : Vec :: with_capacity_in ( capacity, alloc) }
502507 }
503508
504- // XXX: peek_mut
505509 /// Returns a mutable reference to the greatest item in the binary heap, or
506510 /// `None` if it is empty.
507511 ///
@@ -533,7 +537,7 @@ impl<T: Ord, A: Allocator> BinaryHeap<T, A> {
533537 /// If the item is modified then the worst case time complexity is *O*(log(*n*)),
534538 /// otherwise it's *O*(1).
535539 #[ stable( feature = "binary_heap_peek_mut" , since = "1.12.0" ) ]
536- pub fn peek_mut ( & mut self ) -> Option < PeekMut < ' _ , T > > {
540+ pub fn peek_mut ( & mut self ) -> Option < PeekMut < ' _ , T , A > > {
537541 if self . is_empty ( ) {
538542 None
539543 } else {
@@ -1813,7 +1817,7 @@ impl<T: Ord, A: Allocator> Extend<T> for BinaryHeap<T, A> {
18131817}
18141818
18151819#[ stable( feature = "extend_ref" , since = "1.2.0" ) ]
1816- impl < ' a , T : ' a + Ord + Copy > Extend < & ' a T > for BinaryHeap < T > {
1820+ impl < ' a , T : ' a + Ord + Copy , A : Allocator > Extend < & ' a T > for BinaryHeap < T , A > {
18171821 fn extend < I : IntoIterator < Item = & ' a T > > ( & mut self , iter : I ) {
18181822 self . extend ( iter. into_iter ( ) . cloned ( ) ) ;
18191823 }
0 commit comments