xuko-core 0.6.1

Core routines, and data structures for xuko
Documentation
//! Core parts of xuko
//!
//! Contains simple functions, data structures and more.

// data structures
pub mod array;
pub mod bytes;
pub mod sparse_set;

pub mod thread_pool;

/// Re-exports
pub mod prelude {
    pub use crate::{
        array::Array,
        bytes::Bytes,
        sparse_set::SparseSet,
        thread_pool::{ThreadPool, Worker},
    };
}

/// Construct a [`std::collections::HashMap`]
///
/// Example:
/// ```
/// use xuko_core::map;
/// let m1 = map!(String, String);
///
/// let m2 = map!{
///     "abc".to_string() => "def"
/// };
/// ```
#[macro_export]
macro_rules! map {
    // TODO: allow user to specify custom hasher
    ($key:ty, $val:ty) => {
        {
            use ::std::collections::HashMap;
            let map: HashMap<$key, $val> = HashMap::new();
            map
        }
    };

    ($($key: expr => $val:expr),*) => {
        {
            use ::std::collections::HashMap;
            let mut map = HashMap::new();
            $( map.insert($key, $val); )*
            map
        }
    };
}