Skip to main content

with

Function with 

Source
pub fn with<R, FnR>(sym: SymStr, caller: FnR) -> R
where FnR: FnOnce(&str) -> R,
Expand description

Resolve a symbol and call the closure with a &str reference. The closure may safely call pin() or any other arena function — re-entrant access reuses the cached borrow.

§Safety

Uses resolve_uncheckedfrom_utf8_unchecked. Sound because every path into the arena (pin_static(&'static str), pin<S: AsRef<str>>(s), pin_char(c: char)) can only produce a SymStr from content that was already valid UTF-8. The interner’s buffer is append-only by design: once a byte range is associated with a symbol it is never mutated. Callgrind showed the default validating resolve was ~3% of total Ir via str::from_utf8.