Comparing move semantics in C++ and Rust

The phrase “move semantics” always makes me a little bit wary. Jimmy Hartzell has provided this really wonderful overview of the differences between C++ and Rust (and has also made me appreciate Rust’s design even more!):

2 Likes

Corresponding tweet for this thread:

Share link for this tweet.

2 Likes

Yeah Rusts move semantics are far FAR superior from a maintenance standpoint, but they do indeed prevent ‘updating’ internals when something is moved, hence why you can’t have references in them that are not specifically owned elsewhere. I’m hoping that maybe someday there’s some way to get a thing that allows updating internals like that, but make it a specific all, like .move() or so that moves it into, say, a proxy object via a destructive move, then that can be moved around until the actual object is needed again and it’s .into()'d or whatever, thus causing whatever internal updates that need to happen to happen, basically letting you container it up to be inaccessible until you unwrap it again to make it accessible and updated.

2 Likes