[−][src]Struct rustc_builtin_macros::deriving::generic::TraitDef

pub struct TraitDef<'a> {
    pub span: Span,
    pub attributes: Vec<Attribute>,
    pub path: Path,
    pub additional_bounds: Vec<Ty>,
    pub generics: Bounds,
    pub is_unsafe: bool,
    pub supports_unions: bool,
    pub methods: Vec<MethodDef<'a>>,
    pub associated_types: Vec<(Ident, Ty)>,
}

Fields

span: Span

The span for the current #[derive(Foo)] header.

attributes: Vec<Attribute>path: Path

Path of the trait, including any type parameters

additional_bounds: Vec<Ty>

Additional bounds required of any type parameters of the type, other than the current trait

generics: Bounds

Any extra lifetimes and/or bounds, e.g., D: serialize::Decoder

is_unsafe: bool

Is it an unsafe trait?

supports_unions: bool

Can this trait be derived for unions?

methods: Vec<MethodDef<'a>>associated_types: Vec<(Ident, Ty)>

Implementations

impl<'a> TraitDef<'a>[src]

pub fn expand(
    self,
    cx: &mut ExtCtxt<'_>,
    mitem: &MetaItem,
    item: &'a Annotatable,
    push: &mut dyn FnMut(Annotatable)
)
[src]

pub fn expand_ext(
    self,
    cx: &mut ExtCtxt<'_>,
    mitem: &MetaItem,
    item: &'a Annotatable,
    push: &mut dyn FnMut(Annotatable),
    from_scratch: bool
)
[src]

pub(in deriving::generic) fn create_derived_impl(
    &self,
    cx: &mut ExtCtxt<'_>,
    type_ident: Ident,
    generics: &Generics,
    field_tys: Vec<P<Ty>>,
    methods: Vec<P<AssocItem>>
) -> P<Item>
[src]

Given that we are deriving a trait DerivedTrait for a type like:

ⓘThis example is not tested
struct Struct<'a, ..., 'z, A, B: DeclaredTrait, C, ..., Z> where C: WhereTrait {
    a: A,
    b: B::Item,
    b1: <B as DeclaredTrait>::Item,
    c1: <C as WhereTrait>::Item,
    c2: Option<<C as WhereTrait>::Item>,
    ...
}

create an impl like:

ⓘThis example is not tested
impl<'a, ..., 'z, A, B: DeclaredTrait, C, ... Z> where
    C:                       WhereTrait,
    A: DerivedTrait + B1 + ... + BN,
    B: DerivedTrait + B1 + ... + BN,
    C: DerivedTrait + B1 + ... + BN,
    B::Item:                 DerivedTrait + B1 + ... + BN,
    <C as WhereTrait>::Item: DerivedTrait + B1 + ... + BN,
    ...
{
    ...
}

where B1, ..., BN are the bounds given by bounds_paths.'. Z is a phantom type, and therefore does not get bound by the derived trait.

pub(in deriving::generic) fn expand_struct_def(
    &self,
    cx: &mut ExtCtxt<'_>,
    struct_def: &'a VariantData,
    type_ident: Ident,
    generics: &Generics,
    from_scratch: bool,
    use_temporaries: bool
) -> P<Item>
[src]

pub(in deriving::generic) fn expand_enum_def(
    &self,
    cx: &mut ExtCtxt<'_>,
    enum_def: &'a EnumDef,
    type_ident: Ident,
    generics: &Generics,
    from_scratch: bool
) -> P<Item>
[src]

impl<'a> TraitDef<'a>[src]

pub(in deriving::generic) fn summarise_struct(
    &self,
    cx: &mut ExtCtxt<'_>,
    struct_def: &VariantData
) -> StaticFields
[src]

pub(in deriving::generic) fn create_subpatterns(
    &self,
    cx: &mut ExtCtxt<'_>,
    field_paths: Vec<Ident>,
    mutbl: Mutability,
    use_temporaries: bool
) -> Vec<P<Pat>>
[src]

pub(in deriving::generic) fn create_struct_pattern(
    &self,
    cx: &mut ExtCtxt<'_>,
    struct_path: Path,
    struct_def: &'a VariantData,
    prefix: &str,
    mutbl: Mutability,
    use_temporaries: bool
) -> (P<Pat>, Vec<(Span, Option<Ident>, P<Expr>, &'a [Attribute])>)
[src]

pub(in deriving::generic) fn create_enum_variant_pattern(
    &self,
    cx: &mut ExtCtxt<'_>,
    enum_ident: Ident,
    variant: &'a Variant,
    prefix: &str,
    mutbl: Mutability
) -> (P<Pat>, Vec<(Span, Option<Ident>, P<Expr>, &'a [Attribute])>)
[src]

Auto Trait Implementations

impl<'a> !RefUnwindSafe for TraitDef<'a>

impl<'a> !Send for TraitDef<'a>

impl<'a> !Sync for TraitDef<'a>

impl<'a> Unpin for TraitDef<'a>

impl<'a> !UnwindSafe for TraitDef<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.