Skip to content

ref in or-pattern less powerful than match ergonomics #105778

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

Open
lcnr opened this issue Dec 16, 2022 · 0 comments
Open

ref in or-pattern less powerful than match ergonomics #105778

lcnr opened this issue Dec 16, 2022 · 0 comments
Labels
A-patterns Relating to patterns and pattern matching

Comments

@lcnr
Copy link
Contributor

lcnr commented Dec 16, 2022

// error
fn bind_by_ref(x: Option<u32>, y: Option<&u32>) {
    match (x, y) {
        (Some(ref x), _) | (_, Some(x)) => {}
        _ => {}
    }
}

// ok
fn match_ergonomics(x: Option<u32>, y: Option<&u32>) {
    match (&x, y) {
        (Some(x), _) | (_, Some(x)) => {}
        _ => {}
    }
}

ideally bind_by_ref also compiles.

@lcnr lcnr added the A-patterns Relating to patterns and pattern matching label Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-patterns Relating to patterns and pattern matching
Projects
None yet
Development

No branches or pull requests

1 participant