commit | 1b4e2e6247b38f4ad9ffad0b150eac269e4b912d | [log] [tgz] |
---|---|---|
author | Elisei Zamakhov <elisei@google.com> | Thu Jul 11 12:42:35 2024 +0000 |
committer | Elisei Zamakhov <elisei@google.com> | Thu Jul 11 13:51:40 2024 +0000 |
tree | 6efa95f63d3555804589e641ae94d9515d6276c9 | |
parent | 4d3d01ed9d6d33b3047d168963812170b7b9b1c9 [diff] |
Mark apex-available Test: m Change-Id: Ic96d774962e60c6c704caa870ea9563f51b98b92
“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();