Created
December 5, 2022 21:31
-
-
Save ebresafegaga/d04da4cb85d5ef302f286853bb8add4f to your computer and use it in GitHub Desktop.
Trash code
This file contains hidden or 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
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