rune/modules/collections/
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
//! Dynamic collections.

#[cfg(feature = "alloc")]
pub(crate) mod hash_map;
#[cfg(feature = "alloc")]
pub(crate) use hash_map::HashMap;

#[cfg(feature = "alloc")]
pub(crate) mod hash_set;
#[cfg(feature = "alloc")]
pub(crate) use hash_set::HashSet;

#[cfg(feature = "alloc")]
pub(crate) mod vec_deque;
#[cfg(feature = "alloc")]
pub(crate) use vec_deque::VecDeque;

use crate as rune;
use crate::{ContextError, Module};

/// Module defining collections.
#[rune::module(::std::collections)]
pub fn module() -> Result<Module, ContextError> {
    let mut m = Module::from_meta(self::module_meta)?;

    #[cfg(feature = "alloc")]
    m.reexport(
        ["HashMap"],
        rune::item!(::std::collections::hash_map::HashMap),
    )?;

    #[cfg(feature = "alloc")]
    m.reexport(
        ["HashSet"],
        rune::item!(::std::collections::hash_set::HashSet),
    )?;

    #[cfg(feature = "alloc")]
    m.reexport(
        ["VecDeque"],
        rune::item!(::std::collections::vec_deque::VecDeque),
    )?;

    Ok(m)
}