{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreih7mxbghsfmyulc4q5qj7fxa3ug43asplccd55j4khuye7bhh4q2m",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mp2d2iolilg2"
  },
  "path": "/t/a-read-only-no-alias-reference/24410#post_10",
  "publishedAt": "2026-06-24T14:15:30.000Z",
  "site": "https://internals.rust-lang.org",
  "textContent": "Another example:\n\n\n    struct Wrapper<'a>(&'a mut u8);\n\n    impl<'a> Wrapper<'a> {\n        fn increment(&mut self) {\n            *self.0 += 1;\n        }\n    }\n\n    fn main() {\n        let mut a = 13;\n        let b = &mut a;\n        *b += 1;\n        let mut c = Wrapper(b);\n        c.increment();\n    }\n\n\n`b` doesn't have to be marked `mut`, but `c` has to be marked `mut`.\n\nWith read-only unique references the `Wrapper` could work like the built-in `&mut` type and `c` wouldn't need to be `mut`:\n\n\n    struct Wrapper<'a>(&'a mut u8);\n\n    impl<'a> Wrapper<'a> {\n        fn increment(&^ self) {\n            *self.0 += 1;\n        }\n    }\n\n    fn main() {\n        let mut a = 13;\n        let b = &mut a;\n        *b += 1;\n        let c = Wrapper(b);\n        c.increment();\n    }\n\n\nMorgane55440:\n\n> it is a core part of the design of rust that you need `mut` if a variable will ever be modified, but with your idea any `&^self` method could suddenly be modifying non `mut` variable.\n\nThat's not true. Only `mut` variables (such as `a` here) or things inside types with interior mutability (such as `Mutex` in the previous example) could be modified, just like today.",
  "title": "A read only no alias reference"
}