darling_core::codegen::trait_impl

Struct TraitImpl

source
pub struct TraitImpl<'a> {
    pub ident: &'a Ident,
    pub generics: &'a Generics,
    pub data: Data<Variant<'a>, Field<'a>>,
    pub default: Option<DefaultExpression<'a>>,
    pub post_transform: Option<&'a PostfixTransform>,
    pub allow_unknown_fields: bool,
}

Fields§

§ident: &'a Ident§generics: &'a Generics§data: Data<Variant<'a>, Field<'a>>§default: Option<DefaultExpression<'a>>§post_transform: Option<&'a PostfixTransform>§allow_unknown_fields: bool

Implementations§

source§

impl<'a> TraitImpl<'a>

source

pub fn declared_type_params(&self) -> IdentSet

Get all declared type parameters.

source

pub fn used_type_params(&self) -> IdentSet

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.

source

fn type_params_matching<F, V>( &self, field_filter: F, variant_filter: V, ) -> IdentSet
where F: Fn(&&Field<'_>) -> bool, V: Fn(&&Variant<'_>) -> bool,

source

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,

Get the type parameters of all fields in a set matching some filter

source§

impl<'a> TraitImpl<'a>

source

pub fn declare_errors(&self) -> ErrorDeclaration

Gets the let declaration for errors accumulated during parsing.

source

pub fn check_errors(&self) -> ErrorCheck<'_>

Gets the check which performs an early return if errors occurred during parsing.

source

pub(super) fn local_declarations(&self) -> TokenStream

Generate local variable declarations for all fields.

source

pub(super) fn post_transform_call(&self) -> Option<TokenStream>

source

pub(super) fn fallback_decl(&self) -> TokenStream

Generate local variable declaration and initialization for instance from which missing fields will be taken.

source

pub fn require_fields(&self) -> TokenStream

source

pub(super) fn initializers(&self) -> TokenStream

source

pub(super) fn core_loop(&self) -> TokenStream

Generate the loop which walks meta items looking for property matches.

source

fn make_field_ctx(&'a self) -> FieldsGen<'a>

Trait Implementations§

source§

impl<'a> Debug for TraitImpl<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> From<&'a Core> for TraitImpl<'a>

source§

fn from(v: &'a Core) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for TraitImpl<'a>

§

impl<'a> RefUnwindSafe for TraitImpl<'a>

§

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

§

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

§

impl<'a> Unpin for TraitImpl<'a>

§

impl<'a> UnwindSafe for TraitImpl<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.