Skip to content

Documentation update to map.rs as part of tracking issue #107540#154513

Open
KaiPetzke wants to merge 1 commit intorust-lang:mainfrom
KaiPetzke:patch-1
Open

Documentation update to map.rs as part of tracking issue #107540#154513
KaiPetzke wants to merge 1 commit intorust-lang:mainfrom
KaiPetzke:patch-1

Conversation

@KaiPetzke
Copy link
Copy Markdown

@KaiPetzke KaiPetzke commented Mar 28, 2026

As Part of tracking issue #107540, I submit a document 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.

As Part of tracking issue rust-lang#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.
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 28, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 28, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 7 candidates

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 28, 2026

⚠️ Warning ⚠️

  • There are issue links (such as #123) in the commit messages of the following commits.
    Please move them to the PR description, to avoid spamming the issues with references to the commit, and so this bot can automatically canonicalize them to avoid issues with subtree.

/// After the insertion the cursor will be pointing at the gap before the
/// newly inserted element.
/// newly inserted element, effectively inserting the new element after the
/// current cursor position.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I'm not sure this isn't ambiguous too. I think maybe we can rephrase more strongly? Something like:

The cursor remains pointed in the gap after the same element as before the insertion. The next element after the cursor is the newly inserted element.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, an even stronger rephrasing is fine. I just think, we shouldn't use the wording "before the insertion" though, and use the words "before" and "after" exclusively for spatial context (relative ordering in the map) not for timely context (before/after calling a function) to avoid misreading.

A very elaborate version would be:

The new element is inserted into the gap between the two
elements before and after the cursor. When the insertion
completes, the cursor is positioned to point at the gap between
the element before the cursor and the newly inserted element,
so that the newly inserted element will be located after the cursor.

Or another suggestion:

The new element is inserted after the cursor into the gap,
that the cursor is pointing at. When the insertion completes,
the cursor will be pointing at the gap between the item, that
has originally been before the cursor, and the newly inserted
element after it.

But I am also fine with your suggestion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both of those phrasings leave potentially ambiguous the actual behavior, in particular around the cursor not moving. I think the "remains pointed" phrasing from mine helps make it clear relatively succinctly that the cursor has not moved.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 29, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 29, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants