noema 0.4.0

Noema IOC and DI framework for Rust
Documentation
/// Register the compile-time members of a [`Collection`](super::Collection).
///
/// Builds the [`ItemSet`](super::ItemSet) through [`ItemSet::member`](super::ItemSet::member)
/// / [`ItemSet::freeze`](super::ItemSet::freeze); this macro only names the types.
///
/// ```ignore
/// items!(Steps: [StepOne, StepTwo]);
/// items!(Empty: []);
/// ```
#[macro_export]
macro_rules! items {
    ($collection:ty: [$($item:ty),* $(,)?]) => {
        const _: () = {
            use std::sync::{Arc, OnceLock};

            use $crate::items_collections::{ItemList, ItemSet};

            impl ItemList for $collection {
                fn frozen_set() -> Arc<ItemSet<Self>> {
                    static SLOT: OnceLock<Arc<ItemSet<$collection>>> = OnceLock::new();
                    SLOT.get_or_init(|| {
                        ItemSet::<$collection>::freeze([
                            $( ItemSet::<$collection>::member::<$item>(), )*
                        ])
                    })
                    .clone()
                }
            }
        };
    };
}