commit | ef9db0efcb1bac17430a4d461cb155967cbbad40 | [log] [tgz] |
---|---|---|
author | Yimin Li <ymli@google.com> | Fri Oct 21 20:58:05 2022 -0700 |
committer | Yimin Li <ymli@google.com> | Fri Oct 21 20:58:05 2022 -0700 |
tree | da86de748981dd96113865df11834b360d9da02b | |
parent | c3e5b09826dcf15acbe05a8b7941bc6aa0494026 [diff] | |
parent | 6121f74b640ff7bd25f8ac0638ae48fe122761d1 [diff] |
Merge commit '6121f74b640ff7bd25f8ac0638ae48fe122761d1' of sso://googleplex-android/platform/external/rust/crates/smallvec into HEAD Change-Id: Id95ae85f1ed9058b98058b73772a618bc4d9be32
"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();