swc_macros_common::prelude

Trait ItemImplExt

source
pub trait ItemImplExt {
    // Required method
    fn with_generics(self, generics: Generics) -> Self;
}
Expand description

Extension trait for ItemImpl (impl block).

Required Methods§

source

fn with_generics(self, generics: Generics) -> Self

Instead of

let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();

let item: Item = Quote::new(def_site::<Span>())
    .quote_with(smart_quote!(
Vars {
Type: type_name,
impl_generics,
ty_generics,
where_clause,
},
{
impl impl_generics ::swc_common::AstNode for Type ty_generics
where_clause {}
}
)).parse();

You can use this like

    .quote_with(smart_quote!(Vars { Type: type_name }, {
        impl ::swc_common::AstNode for Type {}
    }))
    .parse::<ItemImpl>()
    .with_generics(input.generics);

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ItemImplExt for ItemImpl

source§

fn with_generics(self, generics: Generics) -> Self

Implementors§