pub struct FieldsHelper<'f, T: FieldInfo> { /* private fields */ }
Expand description
Utility struct to work with Fields
Implementations§
Source§impl<'f, T: FieldInfo> FieldsHelper<'f, T>
impl<'f, T: FieldInfo> FieldsHelper<'f, T>
Sourcepub fn new(fields: &'f Fields<T>) -> Self
pub fn new(fields: &'f Fields<T>) -> Self
Builds a new FieldsHelper
Sourcepub fn filtering<P>(self, predicate: P) -> Self
pub fn filtering<P>(self, predicate: P) -> Self
Remove all fields f
for which predicate(&f)
returns false
.
This method operates in place, visiting each element exactly once in the
original order, and preserves the order of the retained elements.
Sourcepub fn with_attributes<P>(self, predicate: P) -> Self
pub fn with_attributes<P>(self, predicate: P) -> Self
Adds an arbitrary number of attributes to each field.
Sourcepub fn extra_default_fields<'a>(
self,
fields: impl IntoIterator<Item = &'a Ident>,
) -> Self
pub fn extra_default_fields<'a>( self, fields: impl IntoIterator<Item = &'a Ident>, ) -> Self
Includes additional default fields by including field1: Default::default(), field2: Default::default(),
It’s only used on named fields, but ignored for tuples.
Sourcepub fn extra_fields<'a>(
self,
fields: impl IntoIterator<Item = &'a Ident>,
) -> Self
pub fn extra_fields<'a>( self, fields: impl IntoIterator<Item = &'a Ident>, ) -> Self
Includes additional fields by including field1: field1, field2: field2,
It’s only used on named fields, but ignored for tuples.
Sourcepub fn extra_fields_with<'a>(
self,
fields: impl IntoIterator<Item = (&'a Ident, impl ToTokens)>,
) -> Self
pub fn extra_fields_with<'a>( self, fields: impl IntoIterator<Item = (&'a Ident, impl ToTokens)>, ) -> Self
Includes additional fields by including field1: expr1, field2: expr2
.
It’s only used on named fields, but ignored for tuples.
Sourcepub fn ignore_extra<'a>(
self,
ignore_extra: impl IntoIterator<Item = &'a Ident>,
) -> Self
pub fn ignore_extra<'a>( self, ignore_extra: impl IntoIterator<Item = &'a Ident>, ) -> Self
Ignore extra fields by including , field1: _ , field2: _
at the end.
It’s only used on named fields, but ignored for tuples.
Sourcepub fn ignore_all_extra(self, ignore_all_extra: bool) -> Self
pub fn ignore_all_extra(self, ignore_all_extra: bool) -> Self
Wether to include , ..
at the end or not, defaults to false
.
Sourcepub fn include_all_default(self, include_all_default: bool) -> Self
pub fn include_all_default(self, include_all_default: bool) -> Self
Wether to include , ..Default::default()
at the end or not, defaults to false
.
Sourcepub fn include_visibility(self, include_visibility: bool) -> Self
pub fn include_visibility(self, include_visibility: bool) -> Self
Wether to include the visibility at the beginning or not, defaults to false
.
Sourcepub fn include_wrapper(self, include_wrapper: bool) -> Self
pub fn include_wrapper(self, include_wrapper: bool) -> Self
Wether to include the wrapper (curly braces for named fields, parenthesis for tuples), defaults to true
.
Sourcepub fn left_collector<C>(self, left_collector: C) -> Self
pub fn left_collector<C>(self, left_collector: C) -> Self
Specifies the left collector. It’s only used with named fields.
Defaults to FieldsCollector::ident
Sourcepub fn right_collector<C>(self, right_collector: C) -> Self
pub fn right_collector<C>(self, right_collector: C) -> Self
Specifies the right collector.
Defaults to FieldsCollector::ty