commit | 8f982420904ee2c56020bb2b93ad6be4e89268de | [log] [tgz] |
---|---|---|
author | Jeff Vander Stoep <jeffv@google.com> | Thu Nov 05 17:06:39 2020 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Thu Nov 05 17:06:39 2020 +0000 |
tree | 5b081fe46bd8d5f84c1fcfcf68c07003059a4866 | |
parent | 736efd0f99ba5a80522a6bf479f9ab1f17ca5d5c [diff] | |
parent | 07e1b850019fd974cc9047ac6412aadc1ce49e45 [diff] |
TEST_MAPPING: test dependers of this crate am: f0c28cc5df am: 07e1b85001 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/smallvec/+/1488808 Change-Id: I9f583467931945acd7ea87d6e8c6ee8e48fd8be2
“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();