External Publication
Visit Post

InteriorAssign trait { a := b }

Rust Internals [Unofficial] May 10, 2026
Source

bluelightzero:

Why would you need it for those cases? You can just a regular = for those.

Right, but the behavior of = is fixed and not overloadable. Yet, overloadable assignment-like operations for a neat shorter syntax would be something that users might want to use. And if we offer it only for interior-mutable primitives, it’d be like encouraging interior mutability onto certain APIs only for the sake of syntactic concisenes.

On the other hand, there are good reasons in favor of keeping assignment non-overloaded; ultimately that’s the only way to really guarantee to all readers of Rust code that writing = really is generally a rather cheap operation.

Discussion in the ATmosphere

Loading comments...