{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreihfhumkrhbw6v5hcifbmrtmg5pyczhic3fk6cz7yzm4ih3fdgvj3i",
    "uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mjkbdahze7n2"
  },
  "path": "/t/pre-pre-rfc-escaping-repetition-operators-in-delimiter-position/24178#post_1",
  "publishedAt": "2026-04-15T15:12:29.000Z",
  "site": "https://internals.rust-lang.org",
  "tags": [
    "Idea: escaping macro separators"
  ],
  "textContent": "Right now there isn't a way to use `+`, `*`, or `?` as a delimiter in a declarative macro. This sucks since `+` and `*` are binary operators which mean they effectively behave as a delimiter in many contexts and being able to match syntax within a macro to the rest of the language or even outside of it is incredibly useful. I propose that escaping a repetition character that is in the delimiter position will do just that, escape the repetition character.\n\nNow while there are a ton of hacky ways to get around this, having official support and making it not hacky will open it up in certain places and generally increase code readability.\n\n### Example:\n\n\n    use core::num::*;\n    use core::ops::*;\n    trait Foo {\n        fn foo(self) -> u32;\n    }\n    macro_rules! foo_for_generic_wrapper {\n        ($W:ident<T$(: $($constraint:ident)\\++>)?) => {\n             impl<T> Foo for $t<T>\n             $(where T: $($constraint)\\++)?\n             {\n                  fn foo(self) -> u32 {\n                        self.0.foo()\n                  }\n             }\n        };\n    }\n    foo_for_generic_wrapper!(Wrapping<T>);\n    foo_for_generic_wrapper!(Saturating<T>);\n    // pretend ZeroablePrimitive is exposed\n    foo_for_generic_wrapper!(NonZero<T: ZeroablePrimitive>);\n    struct FourFunction<T:\n        Add<Self, Output=Self>\n        + Sub<Self, Output=Self>\n        + Mul<Self, Output=Self>\n        + Div<Self, Output=Self>\n    >(T);\n    foo_for_generic_wrapper!(FourFunction<T:\n        Add<Self, Output=Self>\n        + Sub<Self, Output=Self>\n        + Mul<Self, Output=Self>\n        + Div<Self, Output=Self>\n    >);\n\n\nPrevious discussion:\n\n  * Idea: escaping macro separators\n\n",
  "title": "[Pre-Pre RFC] Escaping repetition operators in delimiter position"
}