-
Notifications
You must be signed in to change notification settings - Fork 13.3k
@-pattern documentation in the book is a little misleading #25008
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
Comments
Or at least, the identifier fn main() {
#[derive(Debug)]
struct Recur<'a>(u8, Option<&'a Recur<'a>>);
let r1 = Recur(2, None);
let r2 = Recur(1, Some(&r1));
match r2 {
ref y @ Recur(1, _) | Recur(_, Some(&ref y)) => {
println!("{:?}", y);
}
_ => { println!("other"); }
}
} |
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
May 2, 2015
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
May 2, 2015
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
May 2, 2015
bors
added a commit
that referenced
this issue
May 2, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://doc.rust-lang.org/book/patterns.html#bindings . Current text here for future triage purposes:
The
@
binding is more general than just|
or...
patterns: it can be attached to literally any pattern, e.g.Also, for
|
, the@
has to be attached to each alternative:The text was updated successfully, but these errors were encountered: