commit | fe6c058465d623f386d0f345f9966185fbf55fde | [log] [tgz] |
---|---|---|
author | Eric Arseneau <earseneau@google.com> | Mon Dec 06 14:36:41 2021 -0800 |
committer | Eric Arseneau <earseneau@google.com> | Mon Dec 06 14:36:41 2021 -0800 |
tree | 3ed4f71564f78fb702412335da032629712bf1f3 | |
parent | ee1a348a5c8e55d8e57f7276093f06288be03fa5 [diff] | |
parent | 68978fdf9fe77fdd476add1de8ab9dcc46fb78e2 [diff] |
Merge mpr-2021-11-05 Change-Id: Iae99c8f307ab12865067c4bf9b25c573aaff3574
"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();