Memory management in Rust

Rust has a fine-grained memory management, but it is automatically managed once created. Each variable has a scope in which it is valid, and it is automatically de-allocated when it goes out of scope.

The following code snippet shows an example of memory management:

fn main() {
// 'Slot' is an *owned* value
let slot = box 3i;// The Slot goes out of scope here, it is owner if its data
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.43.140