While lifetimes can arguably be called "regions" in the same sense as in region-based memory management, Rust does not automatically manage memory based on them. Lifetimes are only used for static analysis. Memory is allocated in the normal ways — registers, stack, heap (some C-style malloc
function), possible other abstractions like memory pools if manually implemented as in the typed-arena
crate. This perfectly ordinary memory management is then analyzed by the compiler, using the concept of regions, but that doesn't affect the run time behavior at all. In fact, lifetimes are erased from the program before the machine code is even generated.
However, there might be additional moves in your code. Box::new
is an ordinary function into which the argument is moved, and likewise String::new
's return might involve a move.