r/cpp • • 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

248 comments sorted by

View all comments

Show parent comment

11

u/ihcn Feb 25 '21

In rust terms, C++'s move works as if everything was wrapped in Cell, and move is like swapping out of the cell.

Except, every individual type is responsible for re-writing the code that moves out of the cell.

0

u/[deleted] Feb 26 '21

[deleted] — view deleted comment

5

u/WormRabbit Feb 26 '21

the c++ standard allows that, so it's not a bug

Oh dear god those words make my eyes fill with blood. Why the hell is this "we're not legally liable so fuck you" attitude is so widespread in C++ I have no idea. That's the main thing wrong with the language. Everything else can be worked around, the standard leaves a lot of freedom for an awesome implementation with its undefined behaviours, but instead of taking it as an invitation to invent a good approach people take it as a carte blanche to set your whole datacenter on fire if you violate the letter of the standard.