Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created June 10, 2020 09:00
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 rust-play/c832935c059c5168ce201feed76c73e4 to your computer and use it in GitHub Desktop.
Save rust-play/c832935c059c5168ce201feed76c73e4 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
fn nom_str_until_eol(i: &str) -> nom::IResult<&str, &str> {
let first_line = i.lines().next();
if let Some(first_line) = first_line {
let rest = &i[first_line.len()..];
let rest = rest.trim();
Ok((rest, first_line))
} else {
Ok((i, ""))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment