lookupvec 0.1.3

Container with Vec-like properties that also offers O(1) lookup of items based on an id field
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[cfg(feature = "std")]
#[macro_export]
macro_rules! lookupvec {
    ($($item:expr,)+) => { $crate::lookupvec!($($item),+) };
    ($($item:expr),*) => {
        {
            // Note: `stringify!($item)` is just here to consume the repetition,
            // but we throw away that string literal during constant evaluation.
            const CAP: usize = <[()]>::len(&[$({ stringify!($item); }),*]);
            let mut vec = $crate::LookupVec::with_capacity(CAP);
            $(
                vec.push($item);
            )*
            vec
        }
    };
}