@@ -159,7 +159,7 @@ pub type BinaryHeapView<T, K> = BinaryHeapInner<T, K, ViewVecStorage<T>>;
159159
160160impl < T , K , const N : usize > BinaryHeap < T , K , N > {
161161 /* Constructors */
162- /// Creates an empty BinaryHeap as a $K-heap.
162+ /// Creates an empty ` BinaryHeap` as a $K-heap.
163163 ///
164164 /// ```
165165 /// use heapless::binary_heap::{BinaryHeap, Max};
@@ -184,14 +184,16 @@ impl<T, K, const N: usize> BinaryHeap<T, K, N> {
184184 pub fn into_vec ( self ) -> Vec < T , N > {
185185 self . data
186186 }
187+ }
187188
189+ impl < T , K , S : VecStorage < T > > BinaryHeapInner < T , K , S > {
188190 /// Get a reference to the `BinaryHeap`, erasing the `N` const-generic.
189191 pub fn as_view ( & self ) -> & BinaryHeapView < T , K > {
190- self
192+ S :: as_binary_heap_view ( self )
191193 }
192194 /// Get a mutable reference to the `BinaryHeap`, erasing the `N` const-generic.
193195 pub fn as_mut_view ( & mut self ) -> & mut BinaryHeapView < T , K > {
194- self
196+ S :: as_binary_heap_mut_view ( self )
195197 }
196198}
197199
@@ -203,7 +205,7 @@ where
203205 /* Public API */
204206 /// Returns the capacity of the binary heap.
205207 pub fn capacity ( & self ) -> usize {
206- self . data . storage_capacity ( )
208+ self . data . capacity ( )
207209 }
208210
209211 /// Drops all items from the binary heap.
@@ -222,7 +224,7 @@ where
222224 /// assert!(heap.is_empty());
223225 /// ```
224226 pub fn clear ( & mut self ) {
225- self . data . clear ( )
227+ self . data . clear ( ) ;
226228 }
227229
228230 /// Returns the length of the binary heap.
@@ -386,7 +388,24 @@ where
386388
387389 /// Removes the *top* (greatest if max-heap, smallest if min-heap) item from the binary heap and
388390 /// returns it, without checking if the binary heap is empty.
389- #[ allow( clippy:: missing_safety_doc) ] // TODO
391+ ///
392+ /// # Safety
393+ ///
394+ /// The binary heap must not be empty.
395+ ///
396+ /// # Example
397+ ///
398+ /// ```
399+ /// use heapless::binary_heap::{BinaryHeap, Max};
400+ ///
401+ /// let mut heap: BinaryHeap<_, Max, 8> = BinaryHeap::new();
402+ /// heap.push(42)?;
403+ ///
404+ /// // SAFETY: We just pushed a number onto the heap, so it cannot be empty.
405+ /// let val = unsafe { heap.pop_unchecked() };
406+ /// assert_eq!(val, 42);
407+ /// # Ok::<(), u8>(())
408+ /// ```
390409 pub unsafe fn pop_unchecked ( & mut self ) -> T {
391410 let mut item = self . data . pop_unchecked ( ) ;
392411
@@ -420,7 +439,23 @@ where
420439 }
421440
422441 /// Pushes an item onto the binary heap without first checking if it's full.
423- #[ allow( clippy:: missing_safety_doc) ] // TODO
442+ ///
443+ /// # Safety
444+ ///
445+ /// The binary heap must not be full.
446+ ///
447+ /// # Example
448+ ///
449+ /// ```
450+ /// use heapless::binary_heap::{BinaryHeap, Max};
451+ ///
452+ /// let mut heap: BinaryHeap<_, Max, 8> = BinaryHeap::new();
453+ ///
454+ /// // SAFETY: We just created an empty heap of size 8, so it cannot be full.
455+ /// unsafe { heap.push_unchecked(42) };
456+ /// assert_eq!(heap.len(), 1);
457+ /// assert_eq!(heap.peek(), Some(&42));
458+ /// ```
424459 pub unsafe fn push_unchecked ( & mut self , item : T ) {
425460 let old_len = self . len ( ) ;
426461 self . data . push_unchecked ( item) ;
@@ -596,14 +631,14 @@ where
596631 }
597632}
598633
599- impl < ' a , T , K , S > PeekMutInner < ' a , T , K , S >
634+ impl < T , K , S > PeekMutInner < ' _ , T , K , S >
600635where
601636 T : Ord ,
602637 K : Kind ,
603638 S : VecStorage < T > + ?Sized ,
604639{
605640 /// Removes the peeked value from the heap and returns it.
606- pub fn pop ( mut this : PeekMutInner < ' a , T , K , S > ) -> T {
641+ pub fn pop ( mut this : Self ) -> T {
607642 let value = this. heap . pop ( ) . unwrap ( ) ;
608643 this. sift = false ;
609644 value
0 commit comments