From ca15e9d8a11e7c25eb85930d1da3009647c1680e Mon Sep 17 00:00:00 2001 From: Giacomo Stevanato Date: Sun, 20 Sep 2020 01:07:34 +0200 Subject: [PATCH] Fix time complexity in BinaryHeap::peek_mut docs --- library/alloc/src/collections/binary_heap.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/alloc/src/collections/binary_heap.rs b/library/alloc/src/collections/binary_heap.rs index e3b738a70c888..06e5ac037ca79 100644 --- a/library/alloc/src/collections/binary_heap.rs +++ b/library/alloc/src/collections/binary_heap.rs @@ -399,7 +399,8 @@ impl BinaryHeap { /// /// # Time complexity /// - /// Cost is *O*(1) in the worst case. + /// If the item is modified then the worst case time complexity is *O*(log(*n*)), + /// otherwise it's *O*(1). #[stable(feature = "binary_heap_peek_mut", since = "1.12.0")] pub fn peek_mut(&mut self) -> Option> { if self.is_empty() { None } else { Some(PeekMut { heap: self, sift: false }) }