Enum darling_core::ast::Data
source · pub enum Data<V, F> {
Enum(Vec<V>),
Struct(Fields<F>),
}
Expand description
A struct or enum body.
V
is the type which receives any encountered variants, and F
receives struct fields.
Variants§
Implementations§
source§impl<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>
pub fn map_struct<T, U>(self, map: T) -> Data<V, 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§
source§impl<V: UsesLifetimes, F: UsesLifetimes> UsesLifetimes for Data<V, F>
impl<V: UsesLifetimes, F: UsesLifetimes> UsesLifetimes for Data<V, F>
source§fn 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
source§fn 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.
source§impl<V: UsesTypeParams, F: UsesTypeParams> UsesTypeParams for Data<V, F>
impl<V: UsesTypeParams, F: UsesTypeParams> UsesTypeParams for Data<V, F>
source§fn 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
impl<V: Eq, F: Eq> Eq for Data<V, F>
impl<V, F> StructuralPartialEq for Data<V, F>
Auto Trait Implementations§
impl<V, F> Freeze for Data<V, F>
impl<V, F> RefUnwindSafe for Data<V, F>where
V: RefUnwindSafe,
F: 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>
impl<V, F> UnwindSafe for Data<V, F>where
V: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)