mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-01 17:40:16 +00:00
28 lines
676 B
Rust
28 lines
676 B
Rust
#![feature(prelude_import)]
|
|
#![no_std]
|
|
#![feature(deref_patterns)]
|
|
extern crate std;
|
|
#[prelude_import]
|
|
use ::std::prelude::rust_2015::*;
|
|
|
|
//@ pretty-compare-only
|
|
//@ pretty-mode:expanded
|
|
//@ pp-exact:or-pattern-paren.pp
|
|
|
|
macro_rules! or_pat { ($($name:pat),+) => { $($name)|+ } }
|
|
|
|
fn check_at(x: Option<i32>) {
|
|
match x {
|
|
Some(v @ (1 | 2 | 3)) =>
|
|
|
|
|
|
{
|
|
::std::io::_print(format_args!("{0}\n", v));
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|
|
fn check_ref(x: &i32) { match x { &(1 | 2 | 3) => {} _ => {} } }
|
|
fn check_box(x: Box<i32>) { match x { deref!(1 | 2 | 3) => {} _ => {} } }
|
|
fn main() { check_at(Some(2)); check_ref(&1); check_box(Box::new(1)); }
|