rust/src/test/ui/deref-patterns/basic.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

18 lines
338 B
Rust
Raw Normal View History

// run-pass
// check-run-results
2022-07-05 07:42:19 +00:00
#![feature(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"),
}
2022-07-05 07:42:19 +00:00
}