The optional dependency on `serde` creates an implicit feature, but
we've only been enabling that implementation with `"serde-1"`. Now you
can directly enable `"serde"` to get full use, and `"serde-1"` is just
kept for compatibility.
If we ever need a `"serde-2"`, that can depend on package renaming.
```rust
where
IndexMap<K, V, S>: IndexMut<usize, Output = V>,
IndexSet<T, S>: Index<usize, Output = T>,
```
This allows `map[i]` and `set[i]` indexing to access values directly,
panicking if the index is out of bounds, similar to slices.
On maps, this somewhat overlaps with `Index<&Q> + IndexMut<&Q>` where
`Q: Equivalent<K>`. The reference makes this indexing unambiguous, but
it could be confusing to users if the key type is also an integer.
The fake `std` module we had in our root will make things difficult when
we switch to 2018, where there's a path difference between `std::` for
the crate and `crate::std::` for our module.
These methods trust their caller to pass correct RawBucket values, so we
mark them unsafe to use the common safe/unsafe distinction. I used
allow(unused_unsafe) to write the functions in the (hopefully) future
style of internal unsafe blocks in unsafe functions.
- `pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<(&K, &V)>`
- Stabilized in Rust 1.40.
- This is a middle-ground between `get` and our own `get_full` that
includes the index. It's easy enough to add for compatibility.
- `pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)>`
- Stabilized in Rust 1.27.
- For `IndexMap`, this also adds `swap_`/`shift_remove_entry` choices.
- These are also a middle-ground between (`swap_`/`shift_`)`remove` and
our own `swap`/`shift_remove_full` that include the index. We don't
have a plain `remove_full` though.