{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreibhsgry6c5trcoqw6epeyzmlwl4txorbbayoo3tzngmgkqrw6begq",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mi6xdz7hlq62"
  },
  "path": "/t/pre-pre-rfc-prefacing-items-in-methods-with-self-implements-them-as-associated-items/24115#post_1",
  "publishedAt": "2026-03-28T16:56:54.000Z",
  "site": "https://internals.rust-lang.org",
  "textContent": "The idea is that you'd be allow to define associated items inside methods so you can use associated generics. Visibility would be restricted to inside the function.\n\n### Commented example:\n\n\n    struct Foo<T: Sized> {\n        ...\n    }\n\n    impl<T> Foo<T> {\n        // You can already do this\n        const A: usize = core::mem::size_of::<T>();\n\n        fn foo(&self) {\n            // you still can't do this though.\n            const B: usize = core::mem::size_of::<T>();\n\n            // doing this would be equivalent to defining `B` outside this method,\n            // but in the `impl` block except that it is only visible inside this method.\n            const Self::B: usize = core::mem::size_of::<T>();\n        }\n    }\n",
  "title": "Pre-Pre-RFC: Prefacing items in methods with `Self::` implements them as associated items"
}