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, Global>)
Struct(Fields<F>)
Implementations
sourceimpl<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>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, F> PartialEq<Data<V, F>> for Data<V, F>where
V: PartialEq<V>,
F: PartialEq<F>,
impl<V, F> PartialEq<Data<V, F>> for Data<V, F>where
V: PartialEq<V>,
F: PartialEq<F>,
sourceimpl<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,
sourcefn uses_lifetimes(
&self,
options: &Options,
lifetimes: &'a HashSet<Lifetime, BuildHasherDefault<FnvHasher>>
) -> HashSet<&'a Lifetime, BuildHasherDefault<FnvHasher>>
fn uses_lifetimes(
&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
sourcefn 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.
sourceimpl<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,
sourcefn uses_type_params(
&self,
options: &Options,
type_set: &'a HashSet<Ident, BuildHasherDefault<FnvHasher>>
) -> HashSet<&'a Ident, BuildHasherDefault<FnvHasher>>
fn uses_type_params(
&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
sourcefn 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>where
V: Eq,
F: Eq,
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