daily pastebin goal
63%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 51 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top