macro_rules! fallback_generic_static {
    {$key:ty => static $ident:ident $(: &$type:ty)? = &$init:expr;} => { ... };
}
Expand description

Declare a static variable, keyed by a type. Its type must be a shared reference to a type that implements Sync.

If this is executed for the first time in multiple threads simultaneously, the initializing expression may get executed multiple times.

Available on all targets (falls back to a fast HashMap on non-supported platforms).

Example

#![feature(const_collections_with_hasher)]
fallback_generic_static!(
    T => static NAME = &Mutex::new("Ferris".to_string());
);
// If the type cannot be infered, you can annotate it:
fallback_generic_static!(
    T => static IDS: &Mutex<Vec<i32>> = &Mutex::new(Vec::new());
);