Rust Options Some None using for loop iteratively code example
Example: Rust Options Some None using for loop iteratively
fn find_break(arr: &Vec<i32>) -> Option<i32> {
for i in 1..arr.len() {
if arr[i] - arr[i - 1] != 1 {
return Some(arr[i]);
}
};
None
}
fn main() {
println!("{}", match find_break(&vec![1, 3, 4, 5, 6, 7, 8]) {
Some(s) => s,
None => -1
});
}
//Rust Options Some None using for loop iteratively