swc_allocator/api/
mod.rs

1//! Various flavors of allocator.
2
3/// Re-export for convenience.
4#[cfg(feature = "hashbrown")]
5pub extern crate hashbrown;
6
7/// Types for arena allocator
8pub mod arena {
9    #[allow(unused_imports)]
10    use crate::allocators::Arena;
11
12    /// See [`hashbrown::HashMap`].
13    #[cfg(feature = "hashbrown")]
14    pub type HashMap<'alloc, K, V, S = rustc_hash::FxBuildHasher> =
15        hashbrown::HashMap<K, V, S, &'alloc Arena>;
16
17    /// See [`hashbrown::HashSet`].
18    #[cfg(feature = "hashbrown")]
19    pub type HashSet<'alloc, T, S = rustc_hash::FxBuildHasher> =
20        hashbrown::HashSet<T, S, &'alloc Arena>;
21
22    // /// See [`crate::Box`].
23    // pub type Box<T, A = $alloc> = crate::Box<T, A>;
24
25    // /// See [`std::vec::Vec`].
26    // pub type Vec<T, A = $alloc> = crate::Vec<T, A>;
27}
28
29/// Types for scoped allocator
30pub mod scoped {
31
32    #[allow(unused_imports)]
33    use crate::allocators::Scoped;
34
35    /// See [`hashbrown::HashMap`].
36    #[cfg(feature = "hashbrown")]
37    pub type HashMap<'alloc, K, V, S = rustc_hash::FxBuildHasher> =
38        hashbrown::HashMap<K, V, S, Scoped>;
39
40    /// See [`hashbrown::HashSet`].
41    #[cfg(feature = "hashbrown")]
42    pub type HashSet<'alloc, T, S = rustc_hash::FxBuildHasher> = hashbrown::HashSet<T, S, Scoped>;
43}
44
45/// Types for global allocator
46pub mod global {
47
48    /// See [`hashbrown::HashMap`].
49    #[cfg(feature = "hashbrown")]
50    pub type HashMap<K, V, S = rustc_hash::FxBuildHasher> = hashbrown::HashMap<K, V, S>;
51
52    /// See [`hashbrown::HashSet`].
53    #[cfg(feature = "hashbrown")]
54    pub type HashSet<T, S = rustc_hash::FxBuildHasher> = hashbrown::HashSet<T, S>;
55}