Crates.io | copyvec |
lib.rs | copyvec |
version | 0.1.2 |
source | src |
created_at | 2024-07-11 21:05:17.804494 |
updated_at | 2024-07-13 15:02:28.29009 |
description | A contiguous growable array type, with a fixed, stack-alllocated capacity that implements Copy. |
homepage | https://crates.io/crates/copyvec |
repository | https://github.com/aatifsyed/copyvec |
max_upload_size | |
id | 1300029 |
size | 34,932 |
A stack-allocated sequence that mirror's Vec
's API,
but:
Copy
] (and can only hold [Copy
] types).#[no_std]
/no-alloc
compatible.
// const-friendly
const VEC: CopyVec<&str, 10> = CopyVec::new();
// easy initialising
let mut vec = copyvec!["a", "b", "c"; + 2];
// ^~ with excess capacity
// use the API's you know
vec.push("d");
// including iteration
for it in &mut vec {
if *it == "a" {
*it = "A"
}
}
assert_eq!(vec, ["A", "b", "c", "d"]);
vec.retain(|it| *it == "b" || *it == "c");
assert_eq!(vec.remove(0), "b");
If you like this crate, you may also enjoy stackstack