macro_rules! off_stack {
($ty:ty, $val:expr) => { ... };
}
Expand description
Returns a mutable reference to a value that is stored as a global static
variable rather than exist on the stack.
This is useful for working with large objects that don’t fit on the stack.
It is an alternative to using SingleThreaded
with
RefCell
; RefCell
has the disadvantage of putting
an extra bool
next to the value in memory, which can waste a lot of space
for heavily-aligned objects.
Panics if this function is called recursively, since this would attempt to create multiple mutable references to the same global variable.
This only works in a single-threaded environment.