Trait impl_tools_lib::autoimpl::ImplTrait
source · [−]pub trait ImplTrait {
fn path(&self) -> SimplePath;
fn struct_items(
&self,
item: &ItemStruct,
args: &ImplArgs
) -> Result<(Toks, Toks)>;
fn support_ignore(&self) -> bool { ... }
fn allow_ignore_with(&self) -> Option<SimplePath> { ... }
fn support_using(&self) -> bool { ... }
fn struct_impl(&self, item: &ItemStruct, args: &ImplArgs) -> Result<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_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 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.