commit | 3de05fa51605b3a106364e74240c499663e1b902 | [log] [tgz] |
---|---|---|
author | Chris Wailes <chriswailes@google.com> | Thu May 09 10:49:43 2024 -0700 |
committer | Chris Wailes <chriswailes@google.com> | Thu May 09 10:49:43 2024 -0700 |
tree | f7a5fda58e86abf9d474f8fe19b4356d33fe1039 | |
parent | fb9345fed011e5e1aa3b1404051507cc22be1249 [diff] |
Ensure libstd is used by enabling "write" feature Test: m libsmallvec Bug: 333887339 Change-Id: I572fe112f83a88d3a299554cbc2994bb31063658
"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();