swc_allocator/api/
mod.rs

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
//! Various flavors of allocator.

/// Re-export for convenience.
#[cfg(feature = "hashbrown")]
pub extern crate hashbrown;

/// Types for arena allocator
pub mod arena {
    #[allow(unused_imports)]
    use crate::allocators::Arena;

    /// See [`hashbrown::HashMap`].
    #[cfg(feature = "hashbrown")]
    pub type HashMap<'alloc, K, V, S = rustc_hash::FxBuildHasher> =
        hashbrown::HashMap<K, V, S, &'alloc Arena>;

    /// See [`hashbrown::HashSet`].
    #[cfg(feature = "hashbrown")]
    pub type HashSet<'alloc, T, S = rustc_hash::FxBuildHasher> =
        hashbrown::HashSet<T, S, &'alloc Arena>;

    // /// See [`crate::Box`].
    // pub type Box<T, A = $alloc> = crate::Box<T, A>;

    // /// See [`std::vec::Vec`].
    // pub type Vec<T, A = $alloc> = crate::Vec<T, A>;
}

/// Types for scoped allocator
pub mod scoped {

    #[allow(unused_imports)]
    use crate::allocators::Scoped;

    /// See [`hashbrown::HashMap`].
    #[cfg(feature = "hashbrown")]
    pub type HashMap<'alloc, K, V, S = rustc_hash::FxBuildHasher> =
        hashbrown::HashMap<K, V, S, Scoped>;

    /// See [`hashbrown::HashSet`].
    #[cfg(feature = "hashbrown")]
    pub type HashSet<'alloc, T, S = rustc_hash::FxBuildHasher> = hashbrown::HashSet<T, S, Scoped>;
}

/// Types for global allocator
pub mod global {

    /// See [`hashbrown::HashMap`].
    #[cfg(feature = "hashbrown")]
    pub type HashMap<K, V, S = rustc_hash::FxBuildHasher> = hashbrown::HashMap<K, V, S>;

    /// See [`hashbrown::HashSet`].
    #[cfg(feature = "hashbrown")]
    pub type HashSet<T, S = rustc_hash::FxBuildHasher> = hashbrown::HashSet<T, S>;
}