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) -> Data<V, F>
pub fn empty_from(src: &Data) -> Data<V, F>
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<Data<V, F>, Error>
pub fn try_empty_from(src: &Data) -> Result<Data<V, F>, Error>
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, F> UsesLifetimes for Data<V, F>where
V: UsesLifetimes,
F: UsesLifetimes,
impl<V, F> UsesLifetimes for Data<V, F>where
V: UsesLifetimes,
F: UsesLifetimes,
source§fn uses_lifetimes<'a>(
&self,
options: &Options,
lifetimes: &'a HashSet<Lifetime, BuildHasherDefault<FnvHasher>>,
) -> HashSet<&'a Lifetime, BuildHasherDefault<FnvHasher>>
fn uses_lifetimes<'a>( &self, options: &Options, lifetimes: &'a HashSet<Lifetime, BuildHasherDefault<FnvHasher>>, ) -> HashSet<&'a Lifetime, BuildHasherDefault<FnvHasher>>
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: &HashSet<Lifetime, BuildHasherDefault<FnvHasher>>,
) -> HashSet<Lifetime, BuildHasherDefault<FnvHasher>>
fn uses_lifetimes_cloned( &self, options: &Options, lifetimes: &HashSet<Lifetime, BuildHasherDefault<FnvHasher>>, ) -> HashSet<Lifetime, BuildHasherDefault<FnvHasher>>
Find all used lifetimes, then clone them and return that set.
source§impl<V, F> UsesTypeParams for Data<V, F>where
V: UsesTypeParams,
F: UsesTypeParams,
impl<V, F> UsesTypeParams for Data<V, F>where
V: UsesTypeParams,
F: UsesTypeParams,
source§fn uses_type_params<'a>(
&self,
options: &Options,
type_set: &'a HashSet<Ident, BuildHasherDefault<FnvHasher>>,
) -> HashSet<&'a Ident, BuildHasherDefault<FnvHasher>>
fn uses_type_params<'a>( &self, options: &Options, type_set: &'a HashSet<Ident, BuildHasherDefault<FnvHasher>>, ) -> HashSet<&'a Ident, BuildHasherDefault<FnvHasher>>
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: &HashSet<Ident, BuildHasherDefault<FnvHasher>>,
) -> HashSet<Ident, BuildHasherDefault<FnvHasher>>
fn uses_type_params_cloned( &self, options: &Options, type_set: &HashSet<Ident, BuildHasherDefault<FnvHasher>>, ) -> HashSet<Ident, BuildHasherDefault<FnvHasher>>
Find all type params using
uses_type_params
, then clone the found values and return the set.impl<V, F> 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
)