This code is shown in The Rust Programming Language:
#![feature(box_syntax, box_patterns)]
fn main() {
let b = Some(box 5);
match b {
Some(b
You are using a #[feature] and those can only be used with a nightly Rust compiler. I don't think it is currently possible to match against a Box in stable Rust, but nightly allows the following way of doing it (like you attempted in the beginning):
#![feature(box_patterns)]
fn main() {
let b = Some(Box::new(5));
match b {
Some(box y) => print!("{:?}", y),
_ => print!("{:?}", 1),
}
}