use std::iter::FromIterator; use proc_macro2::TokenTree; use crate::language::*; pub struct QTokens { tokens: Vec, } impl QTokens { pub fn new() -> Self { Self { tokens: vec![] } } pub fn push(&mut self, token: TokenTreeQ) { self.tokens.push(token); } } impl IntoIterator for QTokens { type Item = TokenTreeQ; type IntoIter = as IntoIterator>::IntoIter; fn into_iter(self) -> Self::IntoIter { self.tokens.into_iter() } } impl FromIterator for QTokens { fn from_iter>(iter: T) -> Self { Self { tokens: iter.into_iter().collect(), } } } impl FromIterator for QTokens { fn from_iter>(iter: T) -> Self { Self { tokens: iter.into_iter().map(TokenTreeQ::Plain).collect(), } } } impl From> for QTokens { fn from(tokens: Vec) -> Self { Self { tokens, } } }