commit | c9b20fca295c883c26a3f09d45431e090fb33416 | [log] [tgz] |
---|---|---|
author | Xin Li <delphij@google.com> | Mon Nov 23 11:30:36 2020 -0800 |
committer | Xin Li <delphij@google.com> | Mon Nov 23 11:30:36 2020 -0800 |
tree | 5b081fe46bd8d5f84c1fcfcf68c07003059a4866 | |
parent | 07e1b850019fd974cc9047ac6412aadc1ce49e45 [diff] | |
parent | c35cd24066593df6b72b3f1d3006f0ddb0bd0978 [diff] |
Mark ab/6881855 as merged Bug: 172690556 Change-Id: I93dfc94beb9bd029f1bee83be98b5cf7e7ac3176
“Small vector” optimization for Rust: store up to a small number of items on the stack
use smallvec::{SmallVec, smallvec}; // This SmallVec can hold up to 4 items on the stack: let mut v: SmallVec<[i32; 4]> = smallvec![1, 2, 3, 4]; // It will automatically move its contents to the heap if // contains more than four items: v.push(5); // SmallVec points to a slice, so you can use normal slice // indexing and other methods to access its contents: v[0] = v[1] + v[2]; v.sort();