Skip to content

Instantly share code, notes, and snippets.

@bugaevc
Last active May 2, 2016 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bugaevc/4aac9ea66467e4b99b1c8e451e7ffa8e to your computer and use it in GitHub Desktop.
Save bugaevc/4aac9ea66467e4b99b1c8e451e7ffa8e to your computer and use it in GitHub Desktop.
fn middle_name(full_name: &str) -> &str {
full_name.split_whitespace().nth(1).unwrap()
}
fn main() {
let name = String::from("Harry James Potter");
let res = middle_name(&name);
assert_eq!(res, "James");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment