{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreib6u5clcfwcwniqqvqffm7pny5fuxpd66ckrojgdsgyl54imb5pza",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mp2qhwgipve2"
},
"path": "/t/a-read-only-no-alias-reference/24410#post_13",
"publishedAt": "2026-06-24T17:59:44.000Z",
"site": "https://internals.rust-lang.org",
"textContent": "chrefr:\n\n> It is already possible to do that:\n\nThis doesn't quite work:\n\n\n let a = 42u8;\n let r = ExclusiveReadOnly::new(&a);\n\n\n\n error[E0308]: mismatched types\n --> src/main.rs:19:36\n |\n 19 | let r = ExclusiveReadOnly::new(&a);\n | ---------------------- ^^ types differ in mutability\n | |\n | arguments to this function are incorrect\n\n\n\n let a = 42u8;\n let r = ExclusiveReadOnly::new(&mut a);\n\n\n\n error[E0596]: cannot borrow `a` as mutable, as it is not declared as mutable\n --> src/main.rs:19:36\n |\n 19 | let r = ExclusiveReadOnly::new(&mut a);\n | ^^^^^^ cannot borrow as mutable\n |\n",
"title": "A read only no alias reference"
}