Expand description
Namespaced generic statics with zero-cost access.
Each (Namespace, T) slot is emitted the way clang emits a C++ template
static: a weak, COMDAT-grouped, zero-initialized definition in its own
.bss section. The address is then computed with the optimal
PC-relative sequence for the architecture, so access compiles to 1-2
instructions with no runtime overhead on supported targets.
use core::sync::atomic::{AtomicU64, Ordering};
use static_generics::{define_namespace, namespace::Namespace};
define_namespace!(MyNs);
MyNs::generic_static::<AtomicU64>().store(7, Ordering::Relaxed);
assert_eq!(MyNs::generic_static::<AtomicU64>().load(Ordering::Relaxed), 7);Traitsยง
- Namespace
- A namespace for generic statics.
- Namespace
Ext - Extensions on top of
Namespace::generic_staticto make using generic statics easier.