File tree Expand file tree Collapse file tree 1 file changed +2
-1
lines changed
library/alloc/src/collections Expand file tree Collapse file tree 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> {
293293impl < T : Ord > DerefMut for PeekMut < ' _ , T > {
294294 fn deref_mut ( & mut self ) -> & mut T {
295295 debug_assert ! ( !self . heap. is_empty( ) ) ;
296+ self . sift = true ;
296297 // SAFE: PeekMut is only instantiated for non-empty heaps
297298 unsafe { self . heap . data . get_unchecked_mut ( 0 ) }
298299 }
@@ -401,7 +402,7 @@ impl<T: Ord> BinaryHeap<T> {
401402 /// Cost is *O*(1) in the worst case.
402403 #[ stable( feature = "binary_heap_peek_mut" , since = "1.12.0" ) ]
403404 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 } ) }
405406 }
406407
407408 /// 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