rust-nex/macros/src/util.rs

10 lines
369 B
Rust
Raw Normal View History

2026-05-04 16:06:25 +02:00
use proc_macro2::TokenStream;
use quote::ToTokens;
// todo: return a wrapper struct implementing ToTokens over the iterator instead as to avoid unnescesary allocations with the token stream
pub fn fold_tokenable<T: ToTokens>(list: impl Iterator<Item = T>) -> TokenStream {
list.fold(TokenStream::new(), |mut s, i| {
i.to_tokens(&mut s);
s
})
}