Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn return_word(input: &str, x: usize) -> Result<&str, &str> {
- let mut words = input.split_whitespace();
- if let Some(w) = words.nth(x - 1) {
- Ok(w)
- } else {
- Err("Not enough words")
- }
- }
- fn main() {
- println!("{:?}", return_word("potato cucumber santa snek", 3));
- }
Add Comment
Please, Sign In to add comment