Created
January 22, 2023 20:12
-
-
Save derrickturk/9523818feb18215e28f1e95e2b657d04 to your computer and use it in GitHub Desktop.
"Uncons" a char from a Rust &str
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[inline] | |
fn pop_char(s: &str) -> Option<(char, &str)> { | |
let mut chars = s.chars(); | |
chars.next().map(|c| (c, chars.as_str())) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment