pub trait ImplTrait {
// Required methods
fn path(&self) -> SimplePath;
fn struct_items(
&self,
item: &ItemStruct,
args: &ImplArgs,
) -> Result<(Toks, Toks)>;
// Provided methods
fn support_path_arguments(&self) -> bool { ... }
fn support_ignore(&self) -> bool { ... }
fn allow_ignore_with(&self) -> Option<SimplePath> { ... }
fn support_using(&self) -> bool { ... }
fn enum_impl(&self, item: &ItemEnum, args: &ImplArgs) -> Result<Toks> { ... }
fn struct_impl(&self, item: &ItemStruct, args: &ImplArgs) -> Result<Toks> { ... }
fn enum_items(
&self,
item: &ItemEnum,
args: &ImplArgs,
) -> Result<(Toks, Toks)> { ... }
}
Expand description
Trait required by extensions
Required Methods§
Sourcefn path(&self) -> SimplePath
fn path(&self) -> SimplePath
Trait path
This path is matched against trait names in #[autoimpl]
parameters.
Sourcefn struct_items(
&self,
item: &ItemStruct,
args: &ImplArgs,
) -> Result<(Toks, Toks)>
fn struct_items( &self, item: &ItemStruct, args: &ImplArgs, ) -> Result<(Toks, Toks)>
Generate struct items
On success, this method returns the tuple (trait_path, items)
. These
are used to generate the following implementation:
impl #impl_generics #trait_path for #type_ident #ty_generics #where_clause {
#items
}
Note: this method is only called by the default implementation of Self::struct_impl
.
Provided Methods§
Sourcefn support_path_arguments(&self) -> bool
fn support_path_arguments(&self) -> bool
True if this target supports path arguments
Sourcefn support_ignore(&self) -> bool
fn support_ignore(&self) -> bool
True if this target supports ignoring fields
Default implementation: false
Sourcefn allow_ignore_with(&self) -> Option<SimplePath>
fn allow_ignore_with(&self) -> Option<SimplePath>
If the target does not support ignore
but does tolerate ignore
in
the presence of another target (e.g. autoimpl(Eq, PartialEq ignore self.foo)
),
return the path of that other target here.
Sourcefn support_using(&self) -> bool
fn support_using(&self) -> bool
True if this target supports using a field
Default implementation: false
Sourcefn enum_impl(&self, item: &ItemEnum, args: &ImplArgs) -> Result<Toks>
fn enum_impl(&self, item: &ItemEnum, args: &ImplArgs) -> Result<Toks>
Generate an impl for an enum item
The default implementation is a wrapper around Self::enum_items
and suffices for most cases. It may be overridden, e.g. to generate
multiple implementation items. It is not recommended to modify the
generics.
Sourcefn struct_impl(&self, item: &ItemStruct, args: &ImplArgs) -> Result<Toks>
fn struct_impl(&self, item: &ItemStruct, args: &ImplArgs) -> Result<Toks>
Generate an impl for a struct item
The default implementation is a wrapper around Self::struct_items
and suffices for most cases. It may be overridden, e.g. to generate
multiple implementation items. It is not recommended to modify the
generics.
Sourcefn enum_items(&self, item: &ItemEnum, args: &ImplArgs) -> Result<(Toks, Toks)>
fn enum_items(&self, item: &ItemEnum, args: &ImplArgs) -> Result<(Toks, Toks)>
Generate enum items
On success, this method returns the tuple (trait_path, items)
. These
are used to generate the following implementation:
impl #impl_generics #trait_path for #type_ident #ty_generics #where_clause {
#items
}
Note: this method is only called by the default implementation of Self::enum_impl
.
Default implementation: returns an error indicating that enum expansion is not supported.