use std::borrow::BorrowMut;
use gix_object::TreeRefIter;
use gix_traverse::tree::breadthfirst;
pub trait Sealed {}
pub trait TreeIterExt: Sealed {
fn traverse<StateMut, Find, V>(
&self,
state: StateMut,
objects: Find,
delegate: &mut V,
) -> Result<(), breadthfirst::Error>
where
Find: gix_object::Find,
StateMut: BorrowMut<breadthfirst::State>,
V: gix_traverse::tree::Visit;
}
impl<'d> Sealed for TreeRefIter<'d> {}
impl<'d> TreeIterExt for TreeRefIter<'d> {
fn traverse<StateMut, Find, V>(
&self,
state: StateMut,
objects: Find,
delegate: &mut V,
) -> Result<(), breadthfirst::Error>
where
Find: gix_object::Find,
StateMut: BorrowMut<breadthfirst::State>,
V: gix_traverse::tree::Visit,
{
breadthfirst(*self, state, objects, delegate)
}
}
pub trait TreeEntryRefExt<'a>: 'a {
fn attach<'repo>(self, repo: &'repo crate::Repository) -> crate::object::tree::EntryRef<'repo, 'a>;
}
impl<'a> TreeEntryRefExt<'a> for gix_object::tree::EntryRef<'a> {
fn attach<'repo>(self, repo: &'repo crate::Repository) -> crate::object::tree::EntryRef<'repo, 'a> {
crate::object::tree::EntryRef { inner: self, repo }
}
}
pub trait TreeEntryExt {
fn attach(self, repo: &crate::Repository) -> crate::object::tree::Entry<'_>;
}
impl TreeEntryExt for gix_object::tree::Entry {
fn attach(self, repo: &crate::Repository) -> crate::object::tree::Entry<'_> {
crate::object::tree::Entry { inner: self, repo }
}
}