/// Extension trait for `GenericParam` to support getting values by variant. /// /// # Usage /// `darling::ast::Generics` needs a way to test its params array in order to iterate over type params. /// Rather than require callers to use `darling::ast::GenericParam` in all cases, this trait makes that /// polymorphic. pubtrait GenericParamExt { /// The type this GenericParam uses to represent type params and their bounds type TypeParam; type LifetimeParam; type ConstParam;
/// If this GenericParam is a type param, get the underlying value. fn as_type_param(&self) -> Option<&Self::TypeParam> {
None
}
/// If this GenericParam is a lifetime, get the underlying value. fn as_lifetime_param(&self) -> Option<&Self::LifetimeParam> {
None
}
/// If this GenericParam is a const param, get the underlying value. fn as_const_param(&self) -> Option<&Self::ConstParam> {
None
}
}
impl GenericParamExt for syn::GenericParam { type TypeParam = syn::TypeParam; type LifetimeParam = syn::LifetimeParam; type ConstParam = syn::ConstParam;
/// A mirror of `syn::GenericParam` which is generic over all its contents. #[derive(Debug, Clone, PartialEq, Eq)] pubenum GenericParam<T = syn::TypeParam, L = syn::LifetimeParam, C = syn::ConstParam> { Type(T),
Lifetime(L), Const(C),
}
/// A mirror of the `syn::Generics` type which can contain arbitrary representations /// of params and where clauses. #[derive(Debug, Clone, PartialEq, Eq)] pubstruct Generics<P, W = syn::WhereClause> { pub params: Vec<P>, pub where_clause: Option<W>,
}
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.