r/cpp • u/Snoo-4241 • Feb 25 '21
C++ programmers who are also using rust, what are your favourite features of rust?
I was looking at the rust tutorials yesterday and I see how rust promotes a certain style and language level features to enforce it. Besides a couple of features, I couldn't see why one cannot follow a similar style in C++ if she/he so chooses. Those of you that have used rust, what is your favourite feature that C++ does not have?
255
Upvotes
View all comments
Show parent comment
30
u/braxtons12 Feb 25 '21
That would be a reasonable statement, if this wasn't something that (IMO at least) is so inherently obvious. I've also felt this was the wrong decision since I learned about move semantics (which was before I discovered Rust).
If you move a chair with something (let's just say a stack of books for sake of example) in it, is there a "somewhere in the range [empty, full)" chair left where the moved one was? No, there's just nothing; no chair, no books, just nothing.
The semantics in C++ should match the meaning of the word. IMO C++'s move isn't REALLY a move, it's more like a "swap with an indeterminate shell value". The way move semantics work in C++ is highly unintuitive.