macro_rules! pin {
($s:literal) => { ... };
(concat!($($part:literal),+ $(,)?)) => { ... };
}Expand description
Call-site-cached interning for string literals — the first call on
a thread (after an arena reset) pins the literal via pin_static,
later calls return the cached SymStr directly (a thread-local load,
no arena access). Use this from hot state-key lookup sites so you can keep
writing string literals at the call site and still skip the per-call
pin() hash probe:
if state::lookup_bool_sym(pin!("groupNonBoxing")) { ... }Each call site gets its own thread-local cache (no dedicated pub-static
constant per key), so there is no ergonomic cost beyond typing the macro
name; a site registers in PINNED_SITES on its first pin so that
reset can clear it.
Note: the macro pin! and the runtime-string function
arena::pin(s) share a name but occupy different namespaces in
Rust — pin!(…) is the macro, pin(…) is the function — so both
remain callable.