rust/tests/ui/pattern/deref-patterns/basic.rs
2025-12-31 14:21:38 +11:00

18 lines
372 B
Rust

//@ run-pass
//@ check-run-results
#![feature(deref_patterns)]
#![expect(incomplete_features)]
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"),
}
}