mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-11 13:19:18 +00:00
26 lines
633 B
Rust
26 lines
633 B
Rust
// closure7.rs
|
|
// You can use patterns in closure (and function) parameters.
|
|
// However there is one big difference between the patterns
|
|
// you can use in these sorts of places (like let statements)
|
|
// and conditional places (like match). It's called Irrefutability.
|
|
// Make me compile!
|
|
|
|
// Execute `rustlings hint closures7` for hints!
|
|
|
|
// I AM NOT DONE
|
|
|
|
fn main() {
|
|
|
|
let clo = |(definitely, _)| {
|
|
println!("maybe {:?}", definitely);
|
|
};
|
|
|
|
clo(("oh yes", "oh no"));
|
|
|
|
let maybe = Some("yes");
|
|
let list = vec![maybe];
|
|
|
|
list.iter().inspect(|&Some(value)| {
|
|
println!("maybe {:?}", value);
|
|
});
|
|
} |