Skip to content

Documentation: How does match decide which identifiers bind and which match #3851

New issue

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

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

Already on GitHub? # to your account

Closed
dobesv opened this issue Oct 24, 2012 · 0 comments
Closed
Milestone

Comments

@dobesv
Copy link

dobesv commented Oct 24, 2012

In the example match expression from the manual:

enum List<X> { Nil, Cons(X, @List<X>) }

let x: List<int> = Cons(10, @Cons(11, @Nil));

match x {
    Cons(a, @Cons(b, _)) => {
        process_pair(a,b);
    }
    Cons(10, _) => {
        process_ten();
    }
    Nil => {
        return;
    }
    _ => {
        fail;
    }
}

How is rust deciding that "Nil" here would be "matched" rather than "bound" in the third case?

The documentation could probably use a little clarification on this matter, as there could be a number of possible schemes being used. Some of these schemes are discussed in the "bike shed" but none of the proposals there match the syntax in the manual.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants