commit | 1d11037c6f9ab332ed6f249d6fe64e773cbd916a | [log] [tgz] |
---|---|---|
author | Matthew Maurer <[email protected]> | Thu Mar 09 15:13:53 2023 +0000 |
committer | Automerger Merge Worker <[email protected]> | Thu Mar 09 15:13:53 2023 +0000 |
tree | ea4d3887b79c5a775c7539378ee2bf3a7838ca06 | |
parent | 60b9cf9692294053cd7a6090fb08be1ce3a6cc35 [diff] | |
parent | 48d46cce35a821aa21fc604065d5d911ca3afb61 [diff] |
Make smallvec available to product and vendor am: 48d46cce35 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/smallvec/+/2476461 Change-Id: Id5387566f636c8ce7921e27a7cd2adbf13528b98 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();