fn alloc<T>(t: T) -> &'static T
Expand description
Allocates a given value in a thread-local arena.
This function takes a generic value and allocates it within a thread-local storage arena, then returns a static reference to the allocated object.
It leverages the THR_ARENA
thread-local variable, using its alloc
method to store the value.
The pointer to the allocated memory is then cast to a mutable pointer, and an unsafe operation is performed to convert it into a static reference.
As Rust’s safety guarantees are bypassed here, this code snippet assumes that the reference’s lifetime requirements will be properly managed to prevent undefined behavior.