gix_attributes::search

Struct Outcome

Source
pub struct Outcome { /* private fields */ }
Expand description

The result of a search, containing all matching attributes.

Implementations§

Source§

impl Outcome

Initialization

Source

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.

Source

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

pub fn reset(&mut self)

Prepare for a new search over the known set of attributes by resetting our state.

Source

pub fn copy_into(&self, collection: &MetadataCollection, dest: &mut Self)

A performance optimization which allows results from this instance to be efficiently copied over to dest. For this to work, collection must be the one used to initialize our state, and dest should not have been initialized with any meaningful collection initially, i.e. be empty the first time this method is called.

Note that it’s safe to call it multiple times, so that it can be called after this instance was used to store a search result.

Source§

impl Outcome

Access

Source

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.

Source

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().

Source

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.

Source

pub fn is_done(&self) -> bool

Return true if there is nothing more to be done as all attributes were filled.

Trait Implementations§

Source§

impl Clone for Outcome

Source§

fn clone(&self) -> Outcome

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Outcome

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Outcome

Source§

fn default() -> Outcome

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.