{"action":"closed","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/25008","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/25008/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/25008/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/25008/events","html_url":"https://github.com/rust-lang/rust/issues/25008","id":72303011,"number":25008,"title":"@-pattern documentation in the book is a little misleading","user":{"login":"huonw","id":1203825,"avatar_url":"https://avatars.githubusercontent.com/u/1203825?v=3","gravatar_id":"","url":"https://api.github.com/users/huonw","html_url":"https://github.com/huonw","followers_url":"https://api.github.com/users/huonw/followers","following_url":"https://api.github.com/users/huonw/following{/other_user}","gists_url":"https://api.github.com/users/huonw/gists{/gist_id}","starred_url":"https://api.github.com/users/huonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huonw/subscriptions","organizations_url":"https://api.github.com/users/huonw/orgs","repos_url":"https://api.github.com/users/huonw/repos","events_url":"https://api.github.com/users/huonw/events{/privacy}","received_events_url":"https://api.github.com/users/huonw/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-book","name":"A-book","color":"d7e102"},{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-docs","name":"A-docs","color":"d7e102"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-30T22:52:57Z","updated_at":"2015-05-02T22:33:48Z","closed_at":"2015-05-02T22:33:48Z","body":"http://doc.rust-lang.org/book/patterns.html#bindings . Current text here for future triage purposes:\r\n\r\n> # Bindings\r\n\r\n> If you’re matching multiple things, via a | or a ..., you can bind the value to a name with @:\r\n\r\n> ```rust\r\n> let x = 1;\r\n>\r\n> match x {\r\n>     e @ 1 ... 5 => println!(\"got a range element {}\", e),\r\n>     _ => println!(\"anything\"),\r\n> }\r\n> ```\r\n\r\n> This prints `got a range element 1`.\r\n\r\nThe `@` binding is more general than just `|` or `...` patterns: it can be attached to literally any pattern, e.g.\r\n\r\n```rust\r\nlet mut x: Option<SomeStruct> = ...;\r\nmatch x {\r\n    Some(SomeStruct { a_field: ref a @ Some(_), .. }) => {}\r\n    Some(ref mut b @ SomeStruct { something_else: 5, .. }) => {},\r\n    Some(SomeStruct { third_one: c @ &Ok(_) }) => {},\r\n    _ => {}\r\n}\r\n```\r\n\r\nAlso, for `|`, the `@` has to be attached to each alternative:\r\n\r\n```rust\r\nlet x = 1;\r\nmatch x {\r\n    y @ 1...5 | y @ 10...15 => println!(\"{}\", y),\r\n    _ => {}\r\n}\r\n```"}}