Rust Options Some None using closures code example
Example: Rust Options Some None using closures
fn find_break(arr: &Vec<i32>) -> Option<i32> {
arr.windows(2).find(|arr| arr[1] != arr[0] + 1).map(|arr| arr[1])
}
fn main() {
println!("{}", match find_break(&vec![2, 3, 4, 5, 6, 7, 8]) {
Some(s) => s,
None => -1
});
}
// Rust Options Some None using closures