External Publication
Visit Post

InteriorAssign trait { a := b }

Rust Internals [Unofficial] May 11, 2026
Source

it seems rather obvious to me that InteriorAssign, if it were to exist, ought to be defined as

pub trait InteriorAssign<Rhs = Self> {
    fn interior_assign(&mut self, rhs: Rhs);
}

and a := b would desugar to (&mut a).interior_assign(b), same as all the other *Assign traits.

it still would not work with map[key] := val without some significant compiler magic, but map.entry(key) := val could work at least.

for implementations of mutating traits on types with interior mutability, you may want to look at std::io::Write

Discussion in the ATmosphere

Loading comments...