pub trait GenericParamExt {
    type TypeParam;
    type LifetimeDef;
    type ConstParam;

    // Provided methods
    fn as_type_param(&self) -> Option<&Self::TypeParam> { ... }
    fn as_lifetime_def(&self) -> Option<&Self::LifetimeDef> { ... }
    fn as_const_param(&self) -> Option<&Self::ConstParam> { ... }
}
Expand description

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.

Required Associated Types§

source

type TypeParam

The type this GenericParam uses to represent type params and their bounds

source

type LifetimeDef

source

type ConstParam

Provided Methods§

source

fn as_type_param(&self) -> Option<&Self::TypeParam>

If this GenericParam is a type param, get the underlying value.

source

fn as_lifetime_def(&self) -> Option<&Self::LifetimeDef>

If this GenericParam is a lifetime, get the underlying value.

source

fn as_const_param(&self) -> Option<&Self::ConstParam>

If this GenericParam is a const param, get the underlying value.

Implementations on Foreign Types§

source§

impl GenericParamExt for GenericParam

source§

impl GenericParamExt for TypeParam

Implementors§

source§

impl<T, L, C> GenericParamExt for darling::ast::GenericParam<T, L, C>

§

type TypeParam = T

§

type LifetimeDef = L

§

type ConstParam = C