soa-derive icon indicating copy to clipboard operation
soa-derive copied to clipboard

Derive std::iter::Extend

Open nui opened this issue 3 years ago • 1 comments

Derived vec doesn't implement std::iter::Extend, in order to create struct of array without reallocation, we need to do following code in current version of this crate.

#[derive(StructOfArray)]
Struct Foo {
  foo: String,
}

let vec_of_struct = vec![];
let mut struct_of_vec = FooVec::with_capacity(vec_of_struct.len());
for item in vec_of_struct {
  struct_of_vec.push(item);
}

nui avatar Oct 22 '22 18:10 nui

That's a good point. Adding this trait should not be too hard, although I have very little time for this crate nowadays. I'll be happy to review a PR contributing this feature.

Luthaf avatar Oct 25 '22 12:10 Luthaf