darling_core::codegen::field

Struct Field

source
pub struct Field<'a> {
    pub name_in_attr: Cow<'a, String>,
    pub ident: &'a Ident,
    pub ty: &'a Type,
    pub default_expression: Option<DefaultExpression<'a>>,
    pub with_path: Cow<'a, Path>,
    pub post_transform: Option<&'a PostfixTransform>,
    pub skip: bool,
    pub multiple: bool,
    pub flatten: bool,
}
Expand description

Properties needed to generate code for a field in all the contexts where one may appear.

Fields§

§name_in_attr: Cow<'a, String>

The name presented to the user of the library. This will appear in error messages and will be looked when parsing names.

§ident: &'a Ident

The name presented to the author of the library. This will appear in the setters or temporary variables which contain the values.

§ty: &'a Type

The type of the field in the input.

§default_expression: Option<DefaultExpression<'a>>§with_path: Cow<'a, Path>§post_transform: Option<&'a PostfixTransform>§skip: bool§multiple: bool§flatten: bool

If set, this field will be given all unclaimed meta items and will not be exposed as a standard named field.

Implementations§

source§

impl<'a> Field<'a>

source

pub fn as_name(&'a self) -> Option<&'a str>

Get the name of the meta item that should be matched against input and should be used in diagnostics.

This will be None if the field is skip or flatten, as neither kind of field is addressable by name from the input meta.

source

pub fn as_declaration(&'a self) -> Declaration<'a>

source

pub fn as_flatten_initializer( &'a self, parent_field_names: Vec<&'a str>, ) -> FlattenInitializer<'a>

source

pub fn as_match(&'a self) -> MatchArm<'a>

source

pub fn as_initializer(&'a self) -> Initializer<'a>

source

pub fn as_presence_check(&'a self) -> CheckMissing<'a>

Trait Implementations§

source§

impl<'a> Clone for Field<'a>

source§

fn clone(&self) -> Field<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Field<'a>

source§

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

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

impl<'a> UsesTypeParams for Field<'a>

source§

fn uses_type_params<'b>( &self, options: &Options, type_set: &'b IdentSet, ) -> IdentRefSet<'b>

Returns the subset of the queried type parameters that are used by the implementing syntax element. Read more
source§

fn uses_type_params_cloned( &self, options: &Options, type_set: &IdentSet, ) -> IdentSet

Find all type params using uses_type_params, then clone the found values and return the set.

Auto Trait Implementations§

§

impl<'a> Freeze for Field<'a>

§

impl<'a> RefUnwindSafe for Field<'a>

§

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

§

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

§

impl<'a> Unpin for Field<'a>

§

impl<'a> UnwindSafe for Field<'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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.