You derive Clone on TinyVec/ArrayVec. This means you get the default impl of clone_from, which doesn't allow items stored inside these to reuse their memory. (Ideally, #[derive(Clone)] would do this, but they don't, as it would increase compile time for all rust programs for a rarely-used method. Thankfully, at least all the stdlib container provide impls of this...)
I'm using this for a TinyVec<[FloatImagePlane; 4]> (a float image plane being a Vec<f32> and some metadata). These cane be fairly large, so I'd have an option to have the memory reused.
You derive Clone on TinyVec/ArrayVec. This means you get the default impl of
clone_from
, which doesn't allow items stored inside these to reuse their memory. (Ideally,#[derive(Clone)]
would do this, but they don't, as it would increase compile time for all rust programs for a rarely-used method. Thankfully, at least all the stdlib container provide impls of this...)I'm using this for a
TinyVec<[FloatImagePlane; 4]>
(a float image plane being aVec<f32>
and some metadata). These cane be fairly large, so I'd have an option to have the memory reused.I think this implementation that should work. I didn't write tests, and don't have time to PR it. https://gist.github.com/thomcc/56f9804d23459da4650112a573acf9dd.