Removing Clone requirement
Closed this issue · 1 comments
Would it be possible to somehow remove the T: Clone
restriction for items? I would think that this should improve performance (especially if the T has some complex data), and possibly streamline the code itself?
It might be possible to do with if the PackedItem<T>
would hold references to T, using Packer
for lifetime. Another option (but i'm not certain it will work), is for fn pack()
to take the ownership of the self.items_to_pack
(replacing it with an empty vec), but that seem to conflict with fn pack_into_po2()
which can call pack()
multiple times. Lastly, perhaps the packed structure could just store a vector of usize
, referencing the indexes of self.items_to_pack
.
One thing to note - I believe it would be possible to optimize this only if all public API would become consuming, e.g. pack(self, ...)
instead of pack(&mut self, ...)
(and same for pack_into_po2
)
My appologies, I take this back, it is already possible to use a readonly ref as T