use std::io::{self, Write}; fn find_nemo(word: &str) -> Option { for (i, word) in word.split(" ").enumerate() { if word == "Nemo" { return Some(i + 1); } } None } fn main() { let mut buffer = String::new(); print!("Insert your words: "); io::stdout().flush().expect("Failed to flush stdout."); io::stdin() .read_line(&mut buffer) .expect("Error while trying to read from stdin."); let nemo = find_nemo(&buffer); match nemo { Some(x) => println!("I found Nemo at {}!", x), None => println!("I can't find Nemo :("), } }