Skip to content

Commit ba39a0a

Browse files
authored
Rollup merge of rust-lang#87679 - ssomers:btree_comments, r=joshtriplett
BTree: refine some comments
2 parents 1c4129d + e394bb7 commit ba39a0a

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ mod entry;
1919
pub use entry::{Entry, OccupiedEntry, OccupiedError, VacantEntry};
2020
use Entry::*;
2121

22-
/// Minimum number of elements in nodes that are not a root.
22+
/// Minimum number of elements in a node that is not a root.
2323
/// We might temporarily have fewer elements during methods.
2424
pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT;
2525

2626
// A tree in a `BTreeMap` is a tree in the `node` module with additional invariants:
2727
// - Keys must appear in ascending order (according to the key's type).
28-
// - If the root node is internal, it must contain at least 1 element.
28+
// - Every non-leaf node contains at least 1 element (has at least 2 children).
2929
// - Every non-root node contains at least MIN_LEN elements.
3030
//
31-
// An empty map may be represented both by the absence of a root node or by a
31+
// An empty map is represented either by the absence of a root node or by a
3232
// root node that is an empty leaf.
3333

3434
/// A map based on a [B-Tree].
@@ -1735,8 +1735,8 @@ impl<'a, K: 'a, V: 'a> DrainFilterInner<'a, K, V> {
17351735
pub(super) fn size_hint(&self) -> (usize, Option<usize>) {
17361736
// In most of the btree iterators, `self.length` is the number of elements
17371737
// yet to be visited. Here, it includes elements that were visited and that
1738-
// the predicate decided not to drain. Making this upper bound more accurate
1739-
// requires maintaining an extra field and is not worth while.
1738+
// the predicate decided not to drain. Making this upper bound more tight
1739+
// during iteration would require an extra field.
17401740
(0, Some(*self.length))
17411741
}
17421742
}

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

+2-4
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,7 @@ impl<K, V> Handle<NodeRef<marker::Dying, K, V, marker::Leaf>, marker::Edge> {
440440
/// - The given edge must not have been previously returned by counterpart
441441
/// `deallocating_next_back`.
442442
/// - The returned KV handle is only valid to access the key and value,
443-
/// and only valid until the next call to this method or counterpart
444-
/// `deallocating_next_back`.
443+
/// and only valid until the next call to a `deallocating_` method.
445444
unsafe fn deallocating_next(
446445
self,
447446
) -> Option<(Self, Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>)>
@@ -470,8 +469,7 @@ impl<K, V> Handle<NodeRef<marker::Dying, K, V, marker::Leaf>, marker::Edge> {
470469
/// - The given edge must not have been previously returned by counterpart
471470
/// `deallocating_next`.
472471
/// - The returned KV handle is only valid to access the key and value,
473-
/// and only valid until the next call to this method or counterpart
474-
/// `deallocating_next`.
472+
/// and only valid until the next call to a `deallocating_` method.
475473
unsafe fn deallocating_next_back(
476474
self,
477475
) -> Option<(Self, Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>)>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl<K, V> NodeRef<marker::Owned, K, V, marker::LeafOrInternal> {
574574
/// no cleanup is done on any of the keys, values and other children.
575575
/// This decreases the height by 1 and is the opposite of `push_internal_level`.
576576
///
577-
/// Requires exclusive access to the `Root` object but not to the root node;
577+
/// Requires exclusive access to the `NodeRef` object but not to the root node;
578578
/// it will not invalidate other handles or references to the root node.
579579
///
580580
/// Panics if there is no internal level, i.e., if the root node is a leaf.

0 commit comments

Comments
 (0)