parser: remove deprecated collect_until

This commit is contained in:
Michael Sippel 2023-10-31 16:30:08 +01:00
parent e0c3acab63
commit 903d6dd64f
Signed by: senvas
GPG key ID: 060F22F65102F95C

View file

@ -85,20 +85,11 @@ where It: 'a + Iterator<Item = char> {
} }
} }
pub struct WordLexer<'a, It> pub struct WordLexer<'a, It>
where It: 'a + Iterator<Item = char> { where It: 'a + Iterator<Item = char> {
chars: &'a mut Peekable<It> chars: &'a mut Peekable<It>
} }
impl<'a, It> WordLexer<'a, It>
where It: Iterator<Item = char> {
fn collect_until(&mut self, close: Option<char>) -> Result<String, LexError> {
DelimIter::new(&mut self.chars, vec![(close, true)])
.try_collect::<String>()
}
}
pub struct SubstLexer<'a, It> pub struct SubstLexer<'a, It>
where It: 'a + Iterator<Item = char> { where It: 'a + Iterator<Item = char> {
chars: &'a mut Peekable<It> chars: &'a mut Peekable<It>
@ -140,8 +131,6 @@ where It: Iterator<Item = char>
let word = Word { let word = Word {
segments: SubstLexer { chars: &mut s.chars().peekable() } segments: SubstLexer { chars: &mut s.chars().peekable() }
.try_collect::<Vec<_>>()? .try_collect::<Vec<_>>()?
// .scan((), |_, x| x.ok())
// .collect::<Vec<_>>()
}; };
Ok(WordSegment::DoubleQuote(word)) Ok(WordSegment::DoubleQuote(word))
@ -362,6 +351,7 @@ where It: 'a + Iterator<Item = char> {
// Subshell // Subshell
Some('(') => { Some('(') => {
self.chars.next(); self.chars.next();
let subcmd_str = DelimIter::new(&mut self.chars, vec![(Some(')'), true)]).try_collect::<String>(); let subcmd_str = DelimIter::new(&mut self.chars, vec![(Some(')'), true)]).try_collect::<String>();
match subcmd_str { match subcmd_str {
Ok(subcmd_str) => { Ok(subcmd_str) => {