Guest User

Untitled

a guest
Jul 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. use std::str::Chars;
  2.  
  3. fn scan_name(stream: &mut Chars) -> String {
  4. stream.take_while(|character| !character.is_whitespace() && *character != ':').collect()
  5. }
  6.  
  7. #[test]
  8. fn test_it() {
  9. let foo = "foobar:baz";
  10. assert_eq!(scan_name(&mut foo.chars()), "foobar")
  11. }
Add Comment
Please, Sign In to add comment