mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
18 lines
347 B
Rust
18 lines
347 B
Rust
//@ run-pass
|
|
//@ check-run-results
|
|
#![feature(string_deref_patterns)]
|
|
|
|
fn main() {
|
|
test(Some(String::from("42")));
|
|
test(Some(String::new()));
|
|
test(None);
|
|
}
|
|
|
|
fn test(o: Option<String>) {
|
|
match o {
|
|
Some("42") => println!("the answer"),
|
|
Some(_) => println!("something else?"),
|
|
None => println!("nil"),
|
|
}
|
|
}
|