#[derive(Clone, PartialEq, Eq, Hash, Serialize, Debug)] #[non_exhaustive] pubstruct TraitMethod { pub name: Ident, pub abi_name: Ident, pub self_param: Option<TraitSelfParam>, // corresponds to the types in Function(Vec<Box<TypeName>>, Box<TypeName>) // the callback type; except here the params aren't anonymous pub params: Vec<Param>, pub output_type: Option<TypeName>, pub lifetimes: LifetimeEnv, pub attrs: Attrs, pub docs: Docs,
}
implTrait { /// Extract a [`Trait`] metadata value from an AST node. pubfn new(trt: &syn::ItemTrait, parent_attrs: &Attrs) -> Self { letmut attrs = parent_attrs.clone();
attrs.add_attrs(&trt.attrs);
letmut trait_fcts = Vec::new();
let self_ident = &trt.ident; // TODO check this let self_path_trait = PathType::from(&syn::TraitBound {
paren_token: None,
modifier: syn::TraitBoundModifier::None,
lifetimes: None, // todo this is an assumption
path: syn::PathSegment {
ident: self_ident.clone(),
arguments: syn::PathArguments::None,
}
.into(),
}); for trait_item in trt.items.iter() { iflet syn::TraitItem::Fn(fct) = trait_item { letmut fct_attrs = attrs.clone();
fct_attrs.add_attrs(&fct.attrs); // copied from the method parsing let fct_ident = &fct.sig.ident; let concat_fct_ident = format!("{self_ident}_{fct_ident}"); let extern_ident = syn::Ident::new(
&attrs.abi_rename.apply(concat_fct_ident.into()),
fct.sig.ident.span(),
);
let all_params = fct
.sig
.inputs
.iter()
.filter_map(|a| match a {
syn::FnArg::Receiver(_) => None,
syn::FnArg::Typed(ref t) => {
Some(Param::from_syn(t, self_path_trait.clone()))
}
})
.collect::<Vec<_>>();
let self_param = fct
.sig
.receiver()
.map(|rec| TraitSelfParam::from_syn(rec, self_path_trait.clone()));
let output_type = match &fct.sig.output {
syn::ReturnType::Type(_, return_typ) => Some(TypeName::from_syn(
return_typ.as_ref(),
Some(self_path_trait.clone()),
)),
syn::ReturnType::Default => None,
};
let lifetimes = LifetimeEnv::from_trait_item(
trait_item,
self_param.as_ref(),
&all_params[..],
output_type.as_ref(),
);
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.