-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Currently the only way to extend a StableVec with another vector or slice is repeatedly calling push:
let stable_vec = StableVec::<u8, _>::init(mem).expect("Memory was not for stable vec");
let bytes = bincode::encode_to_vec(value, BINCODE_CONFIG).expect("Failed to serialize value");
for byte in bytes {
stable_vec.push(&byte).expect("StableVec push failed");
}The above code is very memory inefficient as it requires running the entire push code for every element (including growing memory!).
A similar method already exists for the std Vec: Vec::extend
Metadata
Metadata
Assignees
Labels
No labels