File tree 1 file changed +2
-1
lines changed
library/alloc/src/collections
1 file changed +2
-1
lines changed Original file line number Diff line number Diff line change @@ -293,6 +293,7 @@ impl<T: Ord> Deref for PeekMut<'_, T> {
293
293
impl < T : Ord > DerefMut for PeekMut < ' _ , T > {
294
294
fn deref_mut ( & mut self ) -> & mut T {
295
295
debug_assert ! ( !self . heap. is_empty( ) ) ;
296
+ self . sift = true ;
296
297
// SAFE: PeekMut is only instantiated for non-empty heaps
297
298
unsafe { self . heap . data . get_unchecked_mut ( 0 ) }
298
299
}
@@ -401,7 +402,7 @@ impl<T: Ord> BinaryHeap<T> {
401
402
/// Cost is *O*(1) in the worst case.
402
403
#[ stable( feature = "binary_heap_peek_mut" , since = "1.12.0" ) ]
403
404
pub fn peek_mut ( & mut self ) -> Option < PeekMut < ' _ , T > > {
404
- if self . is_empty ( ) { None } else { Some ( PeekMut { heap : self , sift : true } ) }
405
+ if self . is_empty ( ) { None } else { Some ( PeekMut { heap : self , sift : false } ) }
405
406
}
406
407
407
408
/// Removes the greatest item from the binary heap and returns it, or `None` if it
You can’t perform that action at this time.
0 commit comments