moverox_codegen/
generics.rs

1use quote::quote;
2use unsynn::{Ident, TokenStream};
3
4pub(super) trait GenericsExt {
5    fn to_rust(&self) -> TokenStream;
6
7    fn phantoms(&self) -> impl Iterator<Item = &Ident>;
8}
9
10impl GenericsExt for move_syn::Generics {
11    fn to_rust(&self) -> TokenStream {
12        let idents = self.generics().map(|g| &g.ident);
13        quote! {
14            <#(#idents),*>
15        }
16    }
17
18    fn phantoms(&self) -> impl Iterator<Item = &Ident> {
19        self.generics()
20            .filter(|d| d.phantom.is_some())
21            .map(|d| &d.ident)
22    }
23}