]>
Commit | Line | Data |
---|---|---|
6a06907d XL |
1 | //! This crate is a Rust port of Google's high-performance [SwissTable] hash |
2 | //! map, adapted to make it a drop-in replacement for Rust's standard `HashMap` | |
3 | //! and `HashSet` types. | |
4 | //! | |
5 | //! The original C++ version of [SwissTable] can be found [here], and this | |
6 | //! [CppCon talk] gives an overview of how the algorithm works. | |
7 | //! | |
8 | //! [SwissTable]: https://abseil.io/blog/20180927-swisstables | |
9 | //! [here]: https://github.com/abseil/abseil-cpp/blob/master/absl/container/internal/raw_hash_set.h | |
10 | //! [CppCon talk]: https://www.youtube.com/watch?v=ncHmEUmJZf4 | |
11 | ||
12 | #![no_std] | |
13 | #![cfg_attr( | |
14 | feature = "nightly", | |
15 | feature(test, core_intrinsics, dropck_eyepatch, min_specialization, extend_one) | |
16 | )] | |
17 | #![allow( | |
18 | clippy::doc_markdown, | |
19 | clippy::module_name_repetitions, | |
20 | clippy::must_use_candidate, | |
21 | clippy::option_if_let_else | |
22 | )] | |
23 | #![warn(missing_docs)] | |
24 | #![warn(rust_2018_idioms)] | |
25 | ||
26 | #[cfg(test)] | |
27 | #[macro_use] | |
28 | extern crate std; | |
29 | ||
30 | #[cfg_attr(test, macro_use)] | |
31 | extern crate alloc; | |
32 | ||
33 | #[cfg(feature = "nightly")] | |
34 | #[cfg(doctest)] | |
35 | doc_comment::doctest!("../README.md"); | |
36 | ||
37 | #[macro_use] | |
38 | mod macros; | |
39 | ||
40 | #[cfg(feature = "raw")] | |
41 | /// Experimental and unsafe `RawTable` API. This module is only available if the | |
42 | /// `raw` feature is enabled. | |
43 | pub mod raw { | |
44 | // The RawTable API is still experimental and is not properly documented yet. | |
45 | #[allow(missing_docs)] | |
46 | #[path = "mod.rs"] | |
47 | mod inner; | |
48 | pub use inner::*; | |
49 | ||
50 | #[cfg(feature = "rayon")] | |
51 | pub mod rayon { | |
52 | pub use crate::external_trait_impls::rayon::raw::*; | |
53 | } | |
54 | } | |
55 | #[cfg(not(feature = "raw"))] | |
56 | mod raw; | |
57 | ||
58 | mod external_trait_impls; | |
59 | mod map; | |
60 | #[cfg(feature = "rustc-internal-api")] | |
61 | mod rustc_entry; | |
62 | mod scopeguard; | |
63 | mod set; | |
64 | ||
65 | pub mod hash_map { | |
66 | //! A hash map implemented with quadratic probing and SIMD lookup. | |
67 | pub use crate::map::*; | |
68 | ||
69 | #[cfg(feature = "rustc-internal-api")] | |
70 | pub use crate::rustc_entry::*; | |
71 | ||
72 | #[cfg(feature = "rayon")] | |
73 | /// [rayon]-based parallel iterator types for hash maps. | |
74 | /// You will rarely need to interact with it directly unless you have need | |
75 | /// to name one of the iterator types. | |
76 | /// | |
77 | /// [rayon]: https://docs.rs/rayon/1.0/rayon | |
78 | pub mod rayon { | |
79 | pub use crate::external_trait_impls::rayon::map::*; | |
80 | } | |
81 | } | |
82 | pub mod hash_set { | |
83 | //! A hash set implemented as a `HashMap` where the value is `()`. | |
84 | pub use crate::set::*; | |
85 | ||
86 | #[cfg(feature = "rayon")] | |
87 | /// [rayon]-based parallel iterator types for hash sets. | |
88 | /// You will rarely need to interact with it directly unless you have need | |
89 | /// to name one of the iterator types. | |
90 | /// | |
91 | /// [rayon]: https://docs.rs/rayon/1.0/rayon | |
92 | pub mod rayon { | |
93 | pub use crate::external_trait_impls::rayon::set::*; | |
94 | } | |
95 | } | |
96 | ||
97 | pub use crate::map::HashMap; | |
98 | pub use crate::set::HashSet; | |
99 | ||
100 | /// The error type for `try_reserve` methods. | |
101 | #[derive(Clone, PartialEq, Eq, Debug)] | |
102 | pub enum TryReserveError { | |
103 | /// Error due to the computed capacity exceeding the collection's maximum | |
104 | /// (usually `isize::MAX` bytes). | |
105 | CapacityOverflow, | |
106 | ||
107 | /// The memory allocator returned an error | |
108 | AllocError { | |
109 | /// The layout of the allocation request that failed. | |
110 | layout: alloc::alloc::Layout, | |
111 | }, | |
112 | } |