logoalt Hacker News

steveklabnikyesterday at 11:56 PM1 replyview on HN

To further this, "destructive move" as C++ calls it almost happened, but ended up not. So it almost had it the same way as Rust too.


Replies

kmeisthaxtoday at 2:30 AM

The funny thing is, Rust doesn't quite have a destructive move either. Or, at the very least, it's not exposed to the type system. The Drop trait that tells you if a value of a type T was destroyed can only give you a &mut T to it. There's no type to represent a value you own stored in memory you don't. So we have the funny situation where if you implement Drop, you can't take values out of the thing that got dropped.