Guest User

Untitled

a guest
Apr 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. fn return_word(input: &str, x: usize) -> Result<&str, &str> {
  2. let mut words = input.split_whitespace();
  3.  
  4. if let Some(w) = words.nth(x - 1) {
  5. Ok(w)
  6. } else {
  7. Err("Not enough words")
  8. }
  9. }
  10.  
  11. fn main() {
  12. println!("{:?}", return_word("potato cucumber santa snek", 3));
  13. }
Add Comment
Please, Sign In to add comment