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);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ItemImplExt for ItemImpl

Source§

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

Implementors§