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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of typo

typo

Photo of repercussions

repercussions

Photo of C++ & Rust

C++ & Rust

Related news:

News photo

That's not a typo: new T-Mobile deal lands you $1,100 off the Galaxy Z Fold 7 AND a free pair of earbuds, just for kicks

News photo

Under-qualified sysadmin crashed Amazon.com for 3 hours with a typo

News photo

That's not a typo — you can already get the Galaxy Z Flip 7 for FREE with this T-Mobile deal (NO trade-in required!)