| 1 | // This file is part of ICU4X. For terms of use, please see the file |
| 2 | // called LICENSE at the top level of the ICU4X source tree |
| 3 | // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). |
| 4 | |
| 5 | //! # `litemap` |
| 6 | //! |
| 7 | //! `litemap` is a crate providing [`LiteMap`], a highly simplistic "flat" key-value map |
| 8 | //! based off of a single sorted vector. |
| 9 | //! |
| 10 | //! The goal of this crate is to provide a map that is good enough for small |
| 11 | //! sizes, and does not carry the binary size impact of [`HashMap`](std::collections::HashMap) |
| 12 | //! or [`BTreeMap`](alloc::collections::BTreeMap). |
| 13 | //! |
| 14 | //! If binary size is not a concern, [`std::collections::BTreeMap`] may be a better choice |
| 15 | //! for your use case. It behaves very similarly to [`LiteMap`] for less than 12 elements, |
| 16 | //! and upgrades itself gracefully for larger inputs. |
| 17 | //! |
| 18 | //! ## Pluggable Backends |
| 19 | //! |
| 20 | //! By default, [`LiteMap`] is backed by a [`Vec`]; however, it can be backed by any appropriate |
| 21 | //! random-access data store, giving that data store a map-like interface. See the [`store`] |
| 22 | //! module for more details. |
| 23 | //! |
| 24 | //! ## Const construction |
| 25 | //! |
| 26 | //! [`LiteMap`] supports const construction from any store that is const-constructible, such as a |
| 27 | //! static slice, via [`LiteMap::from_sorted_store_unchecked()`]. This also makes [`LiteMap`] |
| 28 | //! suitable for use with [`databake`]. See [`impl Bake for LiteMap`] for more details. |
| 29 | //! |
| 30 | //! [`impl Bake for LiteMap`]: ./struct.LiteMap.html#impl-Bake-for-LiteMap<K,+V,+S> |
| 31 | //! [`Vec`]: alloc::vec::Vec |
| 32 | |
| 33 | // https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations |
| 34 | #![cfg_attr (not(test), no_std)] |
| 35 | #![cfg_attr ( |
| 36 | not(test), |
| 37 | deny( |
| 38 | clippy::indexing_slicing, |
| 39 | clippy::unwrap_used, |
| 40 | clippy::expect_used, |
| 41 | clippy::panic, |
| 42 | clippy::exhaustive_structs, |
| 43 | clippy::exhaustive_enums, |
| 44 | missing_debug_implementations, |
| 45 | ) |
| 46 | )] |
| 47 | |
| 48 | // for intra doc links |
| 49 | #[cfg (doc)] |
| 50 | extern crate std; |
| 51 | |
| 52 | extern crate alloc; |
| 53 | |
| 54 | #[cfg (feature = "databake" )] |
| 55 | #[path = "databake.rs" ] // to not conflict with `databake` as used in the docs |
| 56 | mod databake_impls; |
| 57 | mod map; |
| 58 | #[cfg (feature = "serde" )] |
| 59 | mod serde; |
| 60 | #[cfg (feature = "serde" )] |
| 61 | mod serde_helpers; |
| 62 | pub mod store; |
| 63 | |
| 64 | #[cfg (any(test, feature = "testing" ))] |
| 65 | pub mod testing; |
| 66 | |
| 67 | pub use map::LiteMap; |
| 68 | |