commit | 6a99587c552c521c589581aea3492460e7c5038a | [log] [tgz] |
---|---|---|
author | Matthew Maurer <[email protected]> | Thu Mar 09 17:05:36 2023 +0000 |
committer | Automerger Merge Worker <[email protected]> | Thu Mar 09 17:05:36 2023 +0000 |
tree | ea4d3887b79c5a775c7539378ee2bf3a7838ca06 | |
parent | c004a69014a9474ebfcfa357d7a3afefbf7d78bd [diff] | |
parent | cf55601445f9f90355078ccfcbe320f1fe4a82da [diff] |
Make smallvec available to product and vendor am: 48d46cce35 am: 1d11037c6f am: cf55601445 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/smallvec/+/2476461 Change-Id: I092e6f89fd4245f42c4334a835867a1bf9e8a4be 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();