Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pat macro matcher to be followed by : #2688

Open
GrantMoyer opened this issue Apr 18, 2019 · 1 comment
Open

Allow pat macro matcher to be followed by : #2688

GrantMoyer opened this issue Apr 18, 2019 · 1 comment
Labels
A-macros Macro related proposals and issues A-patterns Pattern matching related proposals & ideas T-lang Relevant to the language team, which will review and decide on the RFC.

Comments

@GrantMoyer
Copy link

GrantMoyer commented Apr 18, 2019

Similarly to #1336, since function parameters can be destructured with patterns:

fn foo((x, y): (u32, u32)) -> u32 {}

pat fragment specifiers should be able to be followed by :. The motivation case for this is something like:

macro_rules! terse {
    ($name:ident($($arg:pat : $type:ty),*) $body:block => {
        fn $name<T>($($arg : $type),*) -> T
            where really::long::and::tedious::Bound<That=Even, Has=Associated> + Types
        $body
    }
}

terse!{bar((x, y): (u32, u32)) {}}
@ExpHP
Copy link

ExpHP commented Apr 23, 2019

Alternatively there is an existing proposal to make pat: ty a valid pat.

(and such considerations were the reason why : was chosen not to be allowed after pat)

@jonas-schievink jonas-schievink added A-macros Macro related proposals and issues A-patterns Pattern matching related proposals & ideas T-lang Relevant to the language team, which will review and decide on the RFC. labels Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macros Macro related proposals and issues A-patterns Pattern matching related proposals & ideas T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

3 participants