-
-
Save swuecho/693c9af0ff9d713a1a6571122964b79e to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ use std::str::FromStr; fn main () { let mut input = "15 Bear".split(' '); // Need to pull the number and parse it. let number = input.next() // Process Option<&'static str> to Option<int> .and_then(|x| i32::from_str(x).ok() ) .expect("Was not provided a valid number."); // The next token is our animal. let animal = input.next() .expect("Was not provided an animal."); // Ouput `number` times. for x in 0 .. number { println!("{} {} says hi!", animal, x) } }