xuko_core/
lib.rs

1//! xuko-core
2//!
3//! Core parts of xuko
4//!
5//! Contains simple functions, data structures and more.
6
7// data structures
8pub mod array;
9pub mod bytes;
10pub mod sparse_set;
11
12pub mod thread_pool;
13
14/// Construct a [`std::collections::HashMap`]
15///
16/// Example:
17/// ```
18/// use xuko_core::map;
19/// let m1 = map!(String, String);
20///
21/// let m2 = map!{
22///     "abc".to_string() => "def"
23/// };
24/// ```
25#[macro_export]
26macro_rules! map {
27    // TODO: allow user to specify custom hasher
28    ($key:ty, $val:ty) => {
29        {
30            use ::std::collections::HashMap;
31            let map: HashMap<$key, $val> = HashMap::new();
32            map
33        }
34    };
35
36    ($($key: expr => $val:expr),*) => {
37        {
38            use ::std::collections::HashMap;
39            let mut map = HashMap::new();
40            $( map.insert($key, $val); )*
41            map
42        }
43    };
44}