Get the latest tech news
The repercussions of a typo in C++ & Rust
missing an Ampersand in C++ & RustCopying vs Passing by reference 30 Aug 2025 TL;DR There’s a funny typo that causes someone to copy data instead of “referencing” in C++. Rust is nice because it provides defaults that protect you from some of these “dumb” mistakes1.
Adopting performance oriented defaults removes a lot of the weird “gotchas” early on in the C++ learning curve, as well as the toil about having the proper tooling setup. Rust prevents us from accidentally writing sub-optimal versions of the C++ function ( BusinessLogic(const Data d))… with the caveat that this choice propagates throughout the language, which can be unintuitive or confusing. The rust library function for removing elements of a vector ( vec::retain) doesn’t give us an option to use a closure that copies by value.
Or read this on Hacker News