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

Adds support for Drop types.

Open remexre opened this issue 2 years ago • 6 comments

remexre avatar Oct 03 '21 03:10 remexre

Could you elaborate a bit on why forwarding to write for each field (i.e. #(self.#fields_names_1.write(val.#fields_names_2); )*) is not sufficient and why this needs to use ManuallyDrop?

Luthaf avatar Oct 04 '21 08:10 Luthaf

Without ManuallyDrop, the original value still gets dropped at the end of the scope, leading to e.g. double-frees.

remexre avatar Oct 04 '21 17:10 remexre

And why not use std::mem::forget?

Luthaf avatar Oct 04 '21 17:10 Luthaf

Either one could work.

remexre avatar Oct 04 '21 17:10 remexre

Ok, I hope I'll have time to do a full review of this (in particular checking that the manually drop/forget was added to all required functions) later this week.

Luthaf avatar Oct 06 '21 14:10 Luthaf

Just had the time to finish the review here. I also rebased on top of master and added another test for ptr::write.

The code looks sound, so if you are happy with the current state I can merge and release this!

Luthaf avatar Nov 27 '21 10:11 Luthaf