Skip to content

Commit 16dc9eb

Browse files
authored
Comment updates to map.rs
As Part of tracking issue #107540, I submit a comment fix (the comments describing the method CursorMut::insert_after_unchecked() should say "before" instead of "after". This can be seen for example from the comments for CursorMutKey::insert_after_unchecked(), which are correct. I further submit a suggestion to make the comments before all Cursor insert methods slightly more verbose to explain the before/after in the names of those methods: insert_after() inserts the new item effectively after the cursor, thus positioning the cursor itself before the new element. I hope the extra verbosity will help to clarify the actual behavior of these methods. No actual code is updated.
1 parent 0d4eb09 commit 16dc9eb

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

  • library/alloc/src/collections/btree

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3405,7 +3405,8 @@ impl<'a, K: Ord, V, A: Allocator + Clone> CursorMutKey<'a, K, V, A> {
34053405
/// cursor is currently pointing to.
34063406
///
34073407
/// After the insertion the cursor will be pointing at the gap before the
3408-
/// newly inserted element.
3408+
/// newly inserted element, effectively inserting the new element after the
3409+
/// current cursor position.
34093410
///
34103411
/// # Safety
34113412
///
@@ -3448,7 +3449,8 @@ impl<'a, K: Ord, V, A: Allocator + Clone> CursorMutKey<'a, K, V, A> {
34483449
/// cursor is currently pointing to.
34493450
///
34503451
/// After the insertion the cursor will be pointing at the gap after the
3451-
/// newly inserted element.
3452+
/// newly inserted element, effectively inserting the new element before
3453+
/// the current cursor position.
34523454
///
34533455
/// # Safety
34543456
///
@@ -3494,7 +3496,8 @@ impl<'a, K: Ord, V, A: Allocator + Clone> CursorMutKey<'a, K, V, A> {
34943496
/// cursor is currently pointing to.
34953497
///
34963498
/// After the insertion the cursor will be pointing at the gap before the
3497-
/// newly inserted element.
3499+
/// newly inserted element, effectively inserting the new element after the
3500+
/// current cursor position.
34983501
///
34993502
/// If the inserted key is not greater than the key before the cursor
35003503
/// (if any), or if it not less than the key after the cursor (if any),
@@ -3522,7 +3525,8 @@ impl<'a, K: Ord, V, A: Allocator + Clone> CursorMutKey<'a, K, V, A> {
35223525
/// cursor is currently pointing to.
35233526
///
35243527
/// After the insertion the cursor will be pointing at the gap after the
3525-
/// newly inserted element.
3528+
/// newly inserted element, effectively inserting the new element before
3529+
/// the current cursor position.
35263530
///
35273531
/// If the inserted key is not greater than the key before the cursor
35283532
/// (if any), or if it not less than the key after the cursor (if any),
@@ -3609,8 +3613,9 @@ impl<'a, K: Ord, V, A: Allocator + Clone> CursorMut<'a, K, V, A> {
36093613
/// Inserts a new key-value pair into the map in the gap that the
36103614
/// cursor is currently pointing to.
36113615
///
3612-
/// After the insertion the cursor will be pointing at the gap after the
3613-
/// newly inserted element.
3616+
/// After the insertion the cursor will be pointing at the gap before the
3617+
/// newly inserted element, effectively inserting the new element after the
3618+
/// current cursor position.
36143619
///
36153620
/// # Safety
36163621
///
@@ -3628,7 +3633,8 @@ impl<'a, K: Ord, V, A: Allocator + Clone> CursorMut<'a, K, V, A> {
36283633
/// cursor is currently pointing to.
36293634
///
36303635
/// After the insertion the cursor will be pointing at the gap after the
3631-
/// newly inserted element.
3636+
/// newly inserted element, effectively inserting the new element before
3637+
/// the current cursor position.
36323638
///
36333639
/// # Safety
36343640
///
@@ -3646,7 +3652,8 @@ impl<'a, K: Ord, V, A: Allocator + Clone> CursorMut<'a, K, V, A> {
36463652
/// cursor is currently pointing to.
36473653
///
36483654
/// After the insertion the cursor will be pointing at the gap before the
3649-
/// newly inserted element.
3655+
/// newly inserted element, effectively inserting the new element after the
3656+
/// current cursor position.
36503657
///
36513658
/// If the inserted key is not greater than the key before the cursor
36523659
/// (if any), or if it not less than the key after the cursor (if any),
@@ -3661,7 +3668,8 @@ impl<'a, K: Ord, V, A: Allocator + Clone> CursorMut<'a, K, V, A> {
36613668
/// cursor is currently pointing to.
36623669
///
36633670
/// After the insertion the cursor will be pointing at the gap after the
3664-
/// newly inserted element.
3671+
/// newly inserted element, effectively inserting the new element before
3672+
/// the current cursor position.
36653673
///
36663674
/// If the inserted key is not greater than the key before the cursor
36673675
/// (if any), or if it not less than the key after the cursor (if any),

0 commit comments

Comments
 (0)