1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
//! More collection types.
//!
//! # Small* collections
//!
//! Built on top of the excellent [smallvec](https://github.com/servo/rust-smallvec)
//! crate, [`SmallMap`] and [`SmallSet`] are a `Map` and `Set` respectively that
//! are inlined if they contain fewer values than a (statically chosen)
//! capacity `C`, otherwise they are heap allocated and backed by an
//! `IndexMap`.
//!
//! # `VecMap`
//!
//! See [`vec_map`] for more details.
//!
//! # Multimap
//!
//! A collection that maps keys to values, similar to [`HashMap`], but where
//! each key may be associated with _multiple_ values. Multimaps can be
//! visualized as a map from keys to non-empty collections of values:
//! - a → 0, 1
//! - b → 2
//!
//! Or, it can be visualized as a collection of key-value pairs:
//! - a → 0
//! - a → 1
//! - b → 2
//!
//! The multimap API is based on the second form, `len() == 3` and `keys_len()
//! == 2` for the above example.
//!
//! | Name | Behaves as | Keys order | Values order | May contain duplicates |
//! | -------------------- | ----------------------------------- | ------------------- |-------------------- | ---------------------- |
//! | [`HashSetMultimap`] | [`HashMap`]`<K,`[`HashSet`]`<V>>` | Arbitrary order | Arbitrary order | No |
//! | [`HashVecMultimap`] | [`HashMap`]`<K,`[`Vec`]`<V>>` | Arbitrary order | Insertion order[^1] | Yes |
//! | [`IndexSetMultimap`] | [`IndexMap`]`<K,`[`IndexSet`]`<V>>` | Insertion order[^1] | Insertion order[^1] | No |
//! | [`IndexVecMultimap`] | [`IndexMap`]`<K, `[`Vec`]`<V>>` | Insertion order[^1] | Insertion order[^1] | Yes |
//!
//! [^1]: Insertion order is preserved, unless `remove()` or `swap_remove()`
//! is called. See more in the [IndexMap](https://docs.rs/indexmap/1.7.0/indexmap/map/struct.IndexMap.html#order) documentation.
//!
//! # Crate features
//! All features are _disabled_ by default. The options are:
//! - `hashsetmultimap`
//! - `hashvecmultimap`
//! - `indexsetmultimap`
//! - `indexvecmultimap`
//!
//! [`HashMap`]: std::collections::HashMap
//! [`HashSet`]: std::collections::HashSet
//! [`IndexMap`]: indexmap::IndexMap
//! [`IndexSet`]: indexmap::IndexSet
//! [`Vec`]: std::vec::Vec
mod multimap;
#[cfg(all(feature = "indexmap", feature = "smallvec", feature = "smallmap"))]
pub mod small_map;
#[cfg(all(
feature = "indexmap",
feature = "smallvec",
feature = "smallmap",
feature = "smallset"
))]
pub mod small_set;
#[cfg(feature = "vecmap")]
pub mod vec_map;
#[cfg(any(
feature = "hashsetmultimap",
feature = "hashvecmultimap",
feature = "indexvecmultimap",
feature = "indexsetmultimap"
))]
pub use multimap::*;
#[cfg(all(feature = "indexmap", feature = "smallvec", feature = "smallmap"))]
pub use small_map::SmallMap;
#[cfg(all(
feature = "indexmap",
feature = "smallvec",
feature = "smallmap",
feature = "smallset"
))]
pub use small_set::SmallSet;
#[cfg(feature = "vecmap")]
pub use vec_map::IndexKey;
#[cfg(feature = "vecmap")]
pub use vec_map::VecMap;
// TODO follow all guidelines here https://rust-lang.github.io/api-guidelines/checklist.html