{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreidrsz6nls5lja6pk5mflb7hxw4q7rtvoaro4n5d72bcslh5x5vnba",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mllg2fc43ut2"
},
"path": "/t/interiorassign-trait-a-b/24291?page=2#post_25",
"publishedAt": "2026-05-11T13:30:34.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"@Morgane55440"
],
"textContent": "I think @Morgane55440 is saying that with the `&mut self` definition you could do something like this:\n\n\n use std::cell::Cell;\n\n pub trait InteriorAssign<Rhs = Self> {\n fn interior_assign(&mut self, rhs: Rhs);\n }\n\n impl<T> InteriorAssign<T> for &Cell<T> {\n \tfn interior_assign(&mut self, rhs: T){\n self.set(rhs);\n \t}\n }\n\n fn main() {\n let mut num = &Cell::new(12);\n num := 13; // (&mut num).interior_assign(13);\n }\n\n\nI'm not sure how the ergonomics would compare to having two separate traits, though.",
"title": "InteriorAssign trait { a := b }"
}