| @@ -5,8 +5,25 @@ use winnow::{error::ParserError, prelude::*}; · 4 unmodified lines |
| 5 | 5 | |
| 6 | 6 | use crate::{tree, tree::EntryRef, TreeRef, TreeRefIter}; |
| 7 | 7 | |
| 8 | | −/// Yes |
| 9 | | −pub fn iter_next<'a, I, P>( |
| 8 | +/// Advance a path lookup by matching the next path component against `tree`. |
| 9 | +/// |
| 10 | +/// `components` must yield the remaining path components to resolve, and `tree` must be the |
| 11 | +/// current object to search in. |
| 12 | +/// |
| 13 | +/// The return value indicates how the caller should proceed: |
| 14 | +/// |
| 15 | +/// - [`ControlFlow::Continue`] contains the object id of the matched entry when there are more |
| 16 | +/// components left to resolve. Callers should load that object and pass it back into a subsequent |
| 17 | +/// invocation. |
| 18 | +/// - [`ControlFlow::Break`]`(Some(entry))` contains the matched entry for the final component, and |
| 19 | +/// signals that lookup completed successfully. |
| 20 | +/// - [`ControlFlow::Break`]`(None)` signals that lookup cannot continue and should stop without a |
| 21 | +/// match. This happens if `tree` is not a tree object, if `components` is already exhausted, or if |
| 22 | +/// the next component is not present in `tree`. |
| 23 | +/// |
| 24 | +/// Note that this behaviour is tuned to prefer to exhaust the entire chain of `components`, only the |
| 25 | +/// last component can yield a [`ControlFlow::Break`]. |
| 26 | +pub fn next_entry<'a, I, P>( |
| 10 | 27 | components: &mut core::iter::Peekable<I>, |
| 11 | 28 | tree: crate::Data<'a>, |
| 12 | 29 | ) -> core::ops::ControlFlow<Option<EntryRef<'a>>, gix_hash::ObjectId> |
| @@ -67,7 +84,7 @@ impl<'a> TreeRefIter<'a> { · 54 unmodified lines |
| 67 | 84 | let mut data = crate::Data::new(crate::Kind::Tree, buffer); |
| 68 | 85 | |
| 69 | 86 | loop { |
| 70 | | − data = match iter_next(&mut iter, data) { |
| 87 | + data = match next_entry(&mut iter, data) { |
| 71 | 88 | ControlFlow::Continue(oid) => { |
| 72 | 89 | let Some(next_tree) = odb.try_find(&oid, buffer)? else { |
| 73 | 90 | break Ok(None); |