Struct gix_attributes::search::Outcome
source · pub struct Outcome { /* private fields */ }Expand description
The result of a search, containing all matching attributes.
Implementations§
source§impl Outcome
impl Outcome
Initialization
sourcepub fn initialize(&mut self, collection: &MetadataCollection)
pub fn initialize(&mut self, collection: &MetadataCollection)
Initialize this instance to collect outcomes for all names in collection, which represents all possible attributes
or macros we may visit, and reset it unconditionally.
This must be called after each time collection changes.
sourcepub fn initialize_with_selection<'a>(
&mut self,
collection: &MetadataCollection,
attribute_names: impl IntoIterator<Item = impl Into<KStringRef<'a>>>
)
pub fn initialize_with_selection<'a>( &mut self, collection: &MetadataCollection, attribute_names: impl IntoIterator<Item = impl Into<KStringRef<'a>>> )
Like initialize(), but limits the set of attributes to look for and fill in
to attribute_names.
Users of this instance should prefer to limit their search as this would allow it to finish earlier.
Note that attribute_names aren’t validated to be valid names here, as invalid names definitely will always be unspecified.
source§impl Outcome
impl Outcome
Access
sourcepub fn iter(&self) -> impl Iterator<Item = Match<'_>>
pub fn iter(&self) -> impl Iterator<Item = Match<'_>>
Return an iterator over all filled attributes we were initialized with.
Note
If initialize_with_selection was used,
use iter_selected() instead.
Deviation
It’s possible that the order in which the attribute are returned (if not limited to a set of attributes) isn’t exactly
the same as what git provides.
Ours is in order of declaration, whereas git seems to list macros first somehow. Since the values are the same, this
shouldn’t be an issue.
sourcepub fn iter_selected(&self) -> impl Iterator<Item = Match<'_>>
pub fn iter_selected(&self) -> impl Iterator<Item = Match<'_>>
Iterate over all matches of the attribute selection in their original order.
This only yields values if this instance was initialized with Outcome::initialize_with_selection().
sourcepub fn match_by_id(&self, id: AttributeId) -> Option<Match<'_>>
pub fn match_by_id(&self, id: AttributeId) -> Option<Match<'_>>
Obtain a match by the order of its attribute, if the order exists in our initialized attribute list and there was a match.