Skip to content

Instantly share code, notes, and snippets.

@ebresafegaga
Created December 5, 2022 21:31
Show Gist options
  • Save ebresafegaga/d04da4cb85d5ef302f286853bb8add4f to your computer and use it in GitHub Desktop.
Save ebresafegaga/d04da4cb85d5ef302f286853bb8add4f to your computer and use it in GitHub Desktop.
Trash code
fn parse_crate<'a, I>(chs: &'a mut I) -> Option<char>
where
I: Iterator<Item = char>,
{
fn is_for_crate<'a, I>(c: char, chs: &'a mut I) -> bool
where
I: Iterator<Item = char>,
{
if c == '[' || c == ']' {
true
} else {
// we want to consume until the next BEFORE the next
// basically eating the whitespace
while let Some(' ') = chs.peekable().peek() {
chs.next();
}
false
}
}
let c = chs.next()?;
is_for_crate(c, chs).then_some(())?; // Eat the first [
let ch = chs.next()?;
let c = chs.next()?;
is_for_crate(c, chs).then_some(())?; // Eat the last ]
chs.next(); // Eat the last space (if any)
Some(ch)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment