use std::env; fn print_usage() { eprintln!("error: usage: piglatin [word] [words]..."); } fn main() { for mut word in env::args().skip(1) { // grab first letter let first = match word.get(0..1) { Some(s) => s, None => { print_usage(); return; } }; // check if first letter is vowel or consonant // if vowel, append -hay and print // if consonant, appent first letter and -ay and print match first { "a" | "e" | "i" | "o" | "u" | "A" | "E" | "I" | "O" | "U" => { print!("{}-hay ", word); }, _ => { let rest = match word.get(1..) { Some(s) => s, None => "", }; print!("{}-{}ay ", rest, first); }, } } println!(); }