Skip to content

Commit 50ee0b2

Browse files
committed
BTreeMap: clean up a few more comments
1 parent efdb859 commit 50ee0b2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

library/alloc/src/collections/btree/node.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> {
179179

180180
/// Removes the internal root node, using its first child as the new root node.
181181
/// As it is intended only to be called when the root node has only one child,
182-
/// no cleanup is done on any of the other children.
182+
/// no cleanup is done on any of the keys, values and other children.
183183
/// This decreases the height by 1 and is the opposite of `push_internal_level`.
184184
///
185185
/// Requires exclusive access to the `Root` object but not to the root node;
@@ -220,7 +220,7 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> {
220220
/// - When this is `Owned`, the `NodeRef` acts roughly like `Box<Node>`,
221221
/// but does not have a destructor, and must be cleaned up manually.
222222
/// Since any `NodeRef` allows navigating through the tree, `BorrowType`
223-
/// effectively applies to the entire tree, not just the node itself.
223+
/// effectively applies to the entire tree, not just to the node itself.
224224
/// - `K` and `V`: These are the types of keys and values stored in the nodes.
225225
/// - `Type`: This can be `Leaf`, `Internal`, or `LeafOrInternal`. When this is
226226
/// `Leaf`, the `NodeRef` points to a leaf node, when this is `Internal` the
@@ -420,7 +420,7 @@ impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Immut<'a>, K, V, Type> {
420420

421421
impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> {
422422
/// Similar to `ascend`, gets a reference to a node's parent node, but also
423-
/// deallocate the current node in the process. This is unsafe because the
423+
/// deallocates the current node in the process. This is unsafe because the
424424
/// current node will still be accessible despite being deallocated.
425425
pub unsafe fn deallocate_and_ascend(
426426
self,
@@ -656,7 +656,10 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
656656
/// Removes a key-value pair from the end of the node and returns the pair.
657657
/// Also removes the edge that was to the right of that pair and, if the node
658658
/// is internal, returns the orphaned subtree that this edge owned.
659-
fn pop(&mut self) -> (K, V, Option<Root<K, V>>) {
659+
///
660+
/// # Safety
661+
/// The node must not be empty.
662+
unsafe fn pop(&mut self) -> (K, V, Option<Root<K, V>>) {
660663
debug_assert!(self.len() > 0);
661664

662665
let idx = self.len() - 1;

library/alloc/src/collections/btree/search.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ pub enum SearchResult<BorrowType, K, V, FoundType, GoDownType> {
1212

1313
/// Looks up a given key in a (sub)tree headed by the given node, recursively.
1414
/// Returns a `Found` with the handle of the matching KV, if any. Otherwise,
15-
/// returns a `GoDown` with the handle of the possible leaf edge where the key
16-
/// belongs.
15+
/// returns a `GoDown` with the handle of the leaf edge where the key belongs.
1716
///
1817
/// The result is meaningful only if the tree is ordered by key, like the tree
1918
/// in a `BTreeMap` is.

0 commit comments

Comments
 (0)