File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -389,7 +389,25 @@ where
389389
390390 /// Removes the *top* (greatest if max-heap, smallest if min-heap) item from the binary heap and
391391 /// returns it, without checking if the binary heap is empty.
392- #[ allow( clippy:: missing_safety_doc) ] // TODO
392+ ///
393+ /// # Safety
394+ ///
395+ /// The binary heap must not be empty.
396+ ///
397+ /// # Example
398+ ///
399+ /// ```
400+ /// use heapless::binary_heap::{BinaryHeap, Max};
401+ ///
402+ /// let mut heap: BinaryHeap<_, Max, 8> = BinaryHeap::new();
403+ /// heap.push(42).unwrap();
404+ ///
405+ /// if !heap.is_empty() {
406+ /// // SAFETY: the heap is not empty
407+ /// let val = unsafe { heap.pop_unchecked() };
408+ /// assert_eq!(val, 42);
409+ /// }
410+ /// ```
393411 pub unsafe fn pop_unchecked ( & mut self ) -> T {
394412 let mut item = self . data . pop_unchecked ( ) ;
395413
You can’t perform that action at this time.
0 commit comments