9 lines
447 B
Plaintext
9 lines
447 B
Plaintext
fn main() {
|
|
let haystack=vec!["Zig", "Zag", "Wally", "Ronald", "Bush", "Krusty", "Charlie",
|
|
"Bush", "Boz", "Zag"];
|
|
|
|
println!("First occurence of 'Bush' at {:?}",haystack.iter().position(|s| *s=="Bush").unwrap());
|
|
println!("Last occurence of 'Bush' at {:?}",haystack.iter().rposition(|s| *s=="Bush").unwrap());
|
|
println!("First occurence of 'Rob' at {:?}",haystack.iter().position(|s| *s=="Rob").unwrap());
|
|
}
|