Idea: traits for zeroizing before and after move

“Move constructors” have been proposed dozens of times in the past, for example:

They’ve been consistently rejected because:

  • “moves are just memcpys” is considered an important and valuable guarantee of Rust, and it’s one lots of unsafe code already relies on, so this is likely not even allowed by our stability policy
  • so far, the major problems for which move constructors have been suggested as a solution (especially self-referencing types) aren’t actually solved by them at all on closer inspection

The zeroing discussions I’ve read so far strongly imply that the second point is true of zeroing too, because there are apparently cases where zeroing on every move is far too slow and instead you want to zero when exiting a function.

2 Likes