impl<'a> TraitImpl<'a> { /// Get all declared type parameters. pubfn declared_type_params(&self) -> IdentSet { self.generics
.type_params()
.map(|tp| tp.ident.clone())
.collect()
}
/// Get the type parameters which are used by non-skipped, non-magic fields. /// These type parameters will have a `FromMeta` bound applied to them in emitted /// code. pubfn used_type_params(&self) -> IdentSet { self.type_params_matching(|f| !f.skip, |v| !v.skip)
}
/// Get the type parameters of all fields in a set matching some filter fn type_params_in_fields<'b, F>(
&'b self,
fields: &'b Fields<Field<'a>>,
field_filter: F,
declared: &IdentSet,
) -> IdentSet where
F: Fn(&&'b Field<'_>) -> bool,
{
fields
.iter()
.filter(field_filter)
.collect_type_params_cloned(&Purpose::BoundImpl.into(), declared)
}
}
impl<'a> TraitImpl<'a> { /// Gets the `let` declaration for errors accumulated during parsing. pubfn declare_errors(&self) -> ErrorDeclaration {
ErrorDeclaration::default()
}
/// Gets the check which performs an early return if errors occurred during parsing. pubfn check_errors(&self) -> ErrorCheck<'_> {
ErrorCheck::default()
}
/// Generate local variable declarations for all fields. pub(incrate::codegen) fn local_declarations(&self) -> TokenStream { iflet Data::Struct(ref vd) = self.data { let vdr = vd.as_ref().map(Field::as_declaration); let decls = vdr.fields.as_slice();
quote!(#(#decls)*)
} else {
quote!()
}
}
/// Generate local variable declaration and initialization for instance from which missing fields will be taken. pub(incrate::codegen) fn fallback_decl(&self) -> TokenStream { let default = self.default.as_ref().map(DefaultExpression::as_declaration);
quote!(#default)
}
pubfn require_fields(&self) -> TokenStream { iflet Data::Struct(ref vd) = self.data { let check_nones = vd.as_ref().map(Field::as_presence_check); let checks = check_nones.fields.as_slice();
// If a field was marked `flatten`, now is the time to process any unclaimed meta items // and mark the field as having been seen. let flatten_field_init = vd.fields.iter().find(|f| f.flatten).map(|v| {
v.as_flatten_initializer(vd.fields.iter().filter_map(Field::as_name).collect())
});
/// Generate the loop which walks meta items looking for property matches. pub(incrate::codegen) fn core_loop(&self) -> TokenStream { self.make_field_ctx().core_loop()
}
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.