Enum darling_core::ast::Data
source · [−]Expand description
A struct or enum body.
V
is the type which receives any encountered variants, and F
receives struct fields.
Variants
Enum(Vec<V>)
Struct(Fields<F>)
Implementations
sourceimpl<V, F> Data<V, F>
impl<V, F> Data<V, F>
sourcepub fn empty_from(src: &Data) -> Self
pub fn empty_from(src: &Data) -> Self
Creates an empty body of the same shape as the passed-in body.
Panics
This function will panic if passed syn::Data::Union
.
sourcepub fn try_empty_from(src: &Data) -> Result<Self>
pub fn try_empty_from(src: &Data) -> Result<Self>
Creates an empty body of the same shape as the passed-in body.
darling
does not support unions; calling this function with a union body will return an error.
sourcepub fn as_ref(&self) -> Data<&V, &F>
pub fn as_ref(&self) -> Data<&V, &F>
Creates a new Data<&'a V, &'a F>
instance from Data<V, F>
.
sourcepub fn map_enum_variants<T, U>(self, map: T) -> Data<U, F>where
T: FnMut(V) -> U,
pub fn map_enum_variants<T, U>(self, map: T) -> Data<U, F>where
T: FnMut(V) -> U,
Applies a function V -> U
on enum variants, if this is an enum.
sourcepub fn map_struct_fields<T, U>(self, map: T) -> Data<V, U>where
T: FnMut(F) -> U,
pub fn map_struct_fields<T, U>(self, map: T) -> Data<V, U>where
T: FnMut(F) -> U,
Applies a function F -> U
on struct fields, if this is a struct.
sourcepub fn map_struct<T, U>(self, map: T) -> Data<V, U>where
T: FnMut(Fields<F>) -> Fields<U>,
pub fn map_struct<T, U>(self, map: T) -> Data<V, U>where
T: FnMut(Fields<F>) -> Fields<U>,
Applies a function to the Fields
if this is a struct.
sourcepub fn take_struct(self) -> Option<Fields<F>>
pub fn take_struct(self) -> Option<Fields<F>>
Consumes the Data
, returning Fields<F>
if it was a struct.
Trait Implementations
sourceimpl<V: PartialEq, F: PartialEq> PartialEq<Data<V, F>> for Data<V, F>
impl<V: PartialEq, F: PartialEq> PartialEq<Data<V, F>> for Data<V, F>
sourceimpl<V: UsesLifetimes, F: UsesLifetimes> UsesLifetimes for Data<V, F>
impl<V: UsesLifetimes, F: UsesLifetimes> UsesLifetimes for Data<V, F>
sourcefn uses_lifetimes<'a>(
&self,
options: &Options,
lifetimes: &'a LifetimeSet
) -> LifetimeRefSet<'a>
fn uses_lifetimes<'a>(
&self,
options: &Options,
lifetimes: &'a LifetimeSet
) -> LifetimeRefSet<'a>
Returns the subset of the queried lifetimes that are used by the implementing syntax element. Read more
sourcefn uses_lifetimes_cloned(
&self,
options: &Options,
lifetimes: &LifetimeSet
) -> LifetimeSet
fn uses_lifetimes_cloned(
&self,
options: &Options,
lifetimes: &LifetimeSet
) -> LifetimeSet
Find all used lifetimes, then clone them and return that set.
sourceimpl<V: UsesTypeParams, F: UsesTypeParams> UsesTypeParams for Data<V, F>
impl<V: UsesTypeParams, F: UsesTypeParams> UsesTypeParams for Data<V, F>
sourcefn uses_type_params<'a>(
&self,
options: &Options,
type_set: &'a IdentSet
) -> IdentRefSet<'a>
fn uses_type_params<'a>(
&self,
options: &Options,
type_set: &'a IdentSet
) -> IdentRefSet<'a>
Returns the subset of the queried type parameters that are used by the implementing syntax element. Read more
sourcefn uses_type_params_cloned(
&self,
options: &Options,
type_set: &IdentSet
) -> IdentSet
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.impl<V: Eq, F: Eq> Eq for Data<V, F>
impl<V, F> StructuralEq for Data<V, F>
impl<V, F> StructuralPartialEq for Data<V, F>
Auto Trait Implementations
impl<V, F> RefUnwindSafe for Data<V, F>where
F: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, F> !Send for Data<V, F>
impl<V, F> !Sync for Data<V, F>
impl<V, F> Unpin for Data<V, F>where
F: Unpin,
V: Unpin,
impl<V, F> UnwindSafe for Data<V, F>where
F: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more