commit | cf55601445f9f90355078ccfcbe320f1fe4a82da | [log] [tgz] |
---|---|---|
author | Matthew Maurer <[email protected]> | Thu Mar 09 16:09:49 2023 +0000 |
committer | Automerger Merge Worker <[email protected]> | Thu Mar 09 16:09:49 2023 +0000 |
tree | ea4d3887b79c5a775c7539378ee2bf3a7838ca06 | |
parent | 76fd734e7f2b76c359e2e849afe60291fbaf26d8 [diff] | |
parent | 1d11037c6f9ab332ed6f249d6fe64e773cbd916a [diff] |
Make smallvec available to product and vendor am: 48d46cce35 am: 1d11037c6f Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/smallvec/+/2476461 Change-Id: Ib73574cdaae8a02122ba6f8e92b1344dcda4da76 Signed-off-by: Automerger Merge Worker <[email protected]>
“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();