Skip to content

docs: say when get_disjoint_mut actually panics - #452

Open
hxperl wants to merge 1 commit into
indexmap-rs:mainfrom
hxperl:docs/get-disjoint-mut-panics
Open

hxperl wants to merge 1 commit into
indexmap-rs:mainfrom
hxperl:docs/get-disjoint-mut-panics

Conversation

@hxperl

@hxperl hxperl commented Sep 15, 2026

Copy link
Copy Markdown

IndexMap::get_disjoint_mut documents an unconditional panic:

/// ***Panics*** if any key is duplicated.
pub fn get_disjoint_mut<Q, const N: usize>(&mut self, keys: [&Q; N]) -> [Option<&mut V>; N]

It does not panic on duplicated keys that are absent from the map — only on duplicates that actually resolve to the same index. Narrowed the claim to what the body does.

The section claims a panic for any duplicated key, but get_disjoint_opt_mut
only reaches the duplicate check inside `if let Some(idx)`, so duplicated
keys that are absent from the map yield None instead of panicking. The
behaviour matches std::collections::HashMap::get_disjoint_mut and is not
changed here; only the doc sentence is corrected.
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.

1 participant