Skip to content

IndexMap and IndexSet: mark remove as deprecated - #680

Merged
sgued merged 3 commits into
rust-embedded:mainfrom
sgued:index-map-set-remove
Jul 29, 2026
Merged

IndexMap and IndexSet: mark remove as deprecated#680
sgued merged 3 commits into
rust-embedded:mainfrom
sgued:index-map-set-remove

Conversation

@sgued

@sgued sgued commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

remove() changed the ordering of the map and this was not made clear in either the documentation or the name, this patch follows the original indexmap crate in using renaming it swap_remove instead

Closes #679

@sgued
sgued requested a review from zeenix July 28, 2026 20:23
@sgued
sgued force-pushed the index-map-set-remove branch from 08c3b2f to 9ec9b41 Compare July 28, 2026 20:24

@zeenix zeenix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM otherwise.

Comment thread src/index_set.rs
Comment thread CHANGELOG.md
Comment thread src/index_map.rs
@sgued
sgued requested a review from zeenix July 29, 2026 11:32
@sgued
sgued force-pushed the index-map-set-remove branch 2 times, most recently from dd93af5 to 9ebfe72 Compare July 29, 2026 11:45
Comment thread src/index_map.rs Outdated
/// **NOTE**: This is equivalent to `.swap_remove_entry()`, replacing this entry’s position
/// with the last element, and it is deprecated in favor of calling that explicitly.
#[deprecated(
note = "`remove` disrupts the map order -- use `swap_remove` for explicit behavior."

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.

Suggested change
note = "`remove` disrupts the map order -- use `swap_remove` for explicit behavior."
note = "`remove_entry` disrupts the map order -- use `swap_remove_entry` for explicit behavior."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@sgued
sgued force-pushed the index-map-set-remove branch from 9ebfe72 to e66a0b1 Compare July 29, 2026 11:58
Comment thread src/index_map.rs
/// let mut map = FnvIndexMap::<_, _, 8>::new();
/// map.insert(1, "a").unwrap();
/// assert_eq!(map.remove(&1), Some("a"));
/// assert_eq!(map.remove(&1), None);

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.

Examples should be moved to the non-deprecated methods.

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.

Ah, they are already there. I'd still remove them from the deprecated methods though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@sgued
sgued force-pushed the index-map-set-remove branch 2 times, most recently from 514654a to e76e999 Compare July 29, 2026 12:08

@zeenix zeenix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All good otherwise IMO. 👍

Comment thread src/index_map.rs Outdated
sgued added 3 commits July 29, 2026 17:16
IndexSet doesn't have any unsafe. This will help ensure any future
`unsafe` is properly documented.
Remove changed the ordering of the map and this was not made clear in
either the documentation or the name, this patch follows the original
indexmap crate in naming it `swap_remove` instead.
@sgued
sgued force-pushed the index-map-set-remove branch from e76e999 to 8a701f5 Compare July 29, 2026 15:27
@sgued
sgued requested a review from zeenix July 29, 2026 15:34
@sgued
sgued added this pull request to the merge queue Jul 29, 2026
Merged via the queue into rust-embedded:main with commit 1be5435 Jul 29, 2026
21 checks passed
@sgued
sgued deleted the index-map-set-remove branch July 29, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IndexMap/IndexSet: deprecate remove() in favour of swap_remove

3 participants