daily pastebin goal
16%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
Top