commit | 7c9a7bcf98727276aec7a793282027003f16fc14 | [log] [tgz] |
---|---|---|
author | Elisei Zamakhov <[email protected]> | Thu Jul 11 12:42:35 2024 +0000 |
committer | Elisei Zamakhov <[email protected]> | Thu Jul 11 13:43:09 2024 +0000 |
tree | 6efa95f63d3555804589e641ae94d9515d6276c9 | |
parent | 4d3d01ed9d6d33b3047d168963812170b7b9b1c9 [diff] |
Mark apex-available Test: m Change-Id: Iec136f4a5c4aee2b229633289d1ef28b1abf6e72
“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();