1#![no_std]
13#![cfg_attr(
14 feature = "nightly",
15 feature(
16 test,
17 core_intrinsics,
18 dropck_eyepatch,
19 min_specialization,
20 extend_one,
21 allocator_api,
22 slice_ptr_get,
23 maybe_uninit_array_assume_init,
24 strict_provenance_lints
25 )
26)]
27#![cfg_attr(feature = "rustc-dep-of-std", feature(rustc_attrs))]
28#![allow(
29 clippy::doc_markdown,
30 clippy::module_name_repetitions,
31 clippy::must_use_candidate,
32 clippy::option_if_let_else,
33 clippy::redundant_else,
34 clippy::manual_map,
35 clippy::missing_safety_doc,
36 clippy::missing_errors_doc
37)]
38#![warn(missing_docs)]
39#![warn(rust_2018_idioms)]
40#![cfg_attr(feature = "nightly", warn(fuzzy_provenance_casts))]
41#![cfg_attr(
42 feature = "nightly",
43 allow(clippy::incompatible_msrv, internal_features)
44)]
45#![cfg_attr(
46 all(feature = "nightly", target_arch = "loongarch64"),
47 feature(stdarch_loongarch)
48)]
49#![cfg_attr(
50 all(feature = "nightly", feature = "default-hasher"),
51 feature(hasher_prefixfree_extras)
52)]
53
54#[cfg(test)]
55#[macro_use]
56extern crate std;
57
58#[cfg_attr(test, macro_use)]
59#[cfg_attr(feature = "rustc-dep-of-std", allow(unused_extern_crates))]
60extern crate alloc;
61
62#[cfg(feature = "nightly")]
63#[cfg(doctest)]
64doc_comment::doctest!("../README.md");
65
66#[macro_use]
67mod macros;
68
69mod control;
70mod hasher;
71mod raw;
72mod util;
73
74mod external_trait_impls;
75mod map;
76#[cfg(feature = "raw-entry")]
77mod raw_entry;
78#[cfg(feature = "rustc-internal-api")]
79mod rustc_entry;
80mod scopeguard;
81mod set;
82mod table;
83
84pub use crate::hasher::DefaultHashBuilder;
85#[cfg(feature = "default-hasher")]
86pub use crate::hasher::DefaultHasher;
87
88pub mod hash_map {
89 pub use crate::map::*;
91
92 #[cfg(feature = "rustc-internal-api")]
93 pub use crate::rustc_entry::*;
94
95 #[cfg(feature = "rayon")]
96 pub mod rayon {
102 pub use crate::external_trait_impls::rayon::map::*;
103 }
104}
105pub mod hash_set {
106 pub use crate::set::*;
108
109 #[cfg(feature = "rayon")]
110 pub mod rayon {
116 pub use crate::external_trait_impls::rayon::set::*;
117 }
118}
119pub mod hash_table {
120 pub use crate::table::*;
122
123 #[cfg(feature = "rayon")]
124 pub mod rayon {
130 pub use crate::external_trait_impls::rayon::table::*;
131 }
132}
133
134pub use crate::map::HashMap;
135pub use crate::set::HashSet;
136pub use crate::table::HashTable;
137
138#[cfg(feature = "equivalent")]
139pub use equivalent::Equivalent;
140
141#[cfg(not(feature = "equivalent"))]
143pub trait Equivalent<K: ?Sized> {
155 fn equivalent(&self, key: &K) -> bool;
164}
165
166#[cfg(not(feature = "equivalent"))]
167impl<Q: ?Sized, K: ?Sized> Equivalent<K> for Q
168where
169 Q: Eq,
170 K: core::borrow::Borrow<Q>,
171{
172 fn equivalent(&self, key: &K) -> bool {
173 self == key.borrow()
174 }
175}
176
177#[derive(Clone, PartialEq, Eq, Debug)]
179pub enum TryReserveError {
180 CapacityOverflow,
183
184 AllocError {
186 layout: alloc::alloc::Layout,
188 },
189}