Logo

Programming-Idioms

History of Idiom 207 > diff from v6 to v7

Edit summary for version 7 by CeaselessBanana:
New Rust implementation by user [CeaselessBanana]

Version 6

2019-11-28, 23:56:01

Version 7

2020-03-17, 13:34:10

Idiom #207 allocate a list that is automatically deallocated

Allocate a list / array a containing n elements (n assumed to be too large for a stack) that is automatically deallocated when the program exits the scope it is declared in.

Idiom #207 allocate a list that is automatically deallocated

Allocate a list / array a containing n elements (n assumed to be too large for a stack) that is automatically deallocated when the program exits the scope it is declared in.

Code
let a = vec![0; n];
Comments bubble
Heap allocations are deallocated when the variable goes out of scope.