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