Is Rust using regional memory management?

For example, if we forget about optimizing the return value and have the following code:

fn func() -> Box<String> {
    Box::new(String::new())
}

fn main() {
    let boxed_string = func();
}

will the compiler create regions for memory management or use the usual heap allocation?

I know that this simple code can be optimized, but in more complex code it may not be so.

+4
source share
1 answer

"" , , Rust . . :— , , ( C-style malloc), , , , typed-arena. , , . , , .

. Box::new - , , String::new .

+10

Source: https://habr.com/ru/post/1654481/


All Articles