Skip to content

Commit

Permalink
fix: `object::tree::diff::Platform::for_each_to_obtain_tree(callback)…
Browse files Browse the repository at this point in the history
…` errors are more convenient to use. (#670)

Due to a change in how the generic error type is declared it should now be possible to
use `anyhow` with it as well.
  • Loading branch information
Byron committed Jan 1, 2024
1 parent 03ec4e9 commit e3c5a0f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions gix/src/object/tree/diff/for_each.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<'a, 'old> Platform<'a, 'old> {
for_each: impl FnMut(Change<'_, 'old, 'new>) -> Result<Action, E>,
) -> Result<Outcome, Error>
where
E: std::error::Error + Sync + Send + 'static,
E: Into<Box<dyn std::error::Error + Sync + Send + 'static>>,
{
self.for_each_to_obtain_tree_inner(other, for_each, None)
}
Expand All @@ -64,7 +64,7 @@ impl<'a, 'old> Platform<'a, 'old> {
for_each: impl FnMut(Change<'_, 'old, 'new>) -> Result<Action, E>,
) -> Result<Outcome, Error>
where
E: std::error::Error + Sync + Send + 'static,
E: Into<Box<dyn std::error::Error + Sync + Send + 'static>>,
{
self.for_each_to_obtain_tree_inner(other, for_each, Some(resource_cache))
}
Expand All @@ -76,7 +76,7 @@ impl<'a, 'old> Platform<'a, 'old> {
resource_cache: Option<&mut gix_diff::blob::Platform>,
) -> Result<Outcome, Error>
where
E: std::error::Error + Sync + Send + 'static,
E: Into<Box<dyn std::error::Error + Sync + Send + 'static>>,
{
let repo = self.lhs.repo;
let mut delegate = Delegate {
Expand All @@ -99,14 +99,14 @@ impl<'a, 'old> Platform<'a, 'old> {
rewrites: delegate.process_tracked_changes(resource_cache)?,
};
match delegate.err {
Some(err) => Err(Error::ForEach(Box::new(err))),
Some(err) => Err(Error::ForEach(err.into())),
None => Ok(outcome),
}
}
Err(gix_diff::tree::changes::Error::Cancelled) => delegate
.err
.map_or(Err(Error::Diff(gix_diff::tree::changes::Error::Cancelled)), |err| {
Err(Error::ForEach(Box::new(err)))
Err(Error::ForEach(err.into()))
}),
Err(err) => Err(err.into()),
}
Expand All @@ -126,7 +126,7 @@ struct Delegate<'a, 'old, 'new, VisitFn, E> {
impl<'a, 'old, 'new, VisitFn, E> Delegate<'a, 'old, 'new, VisitFn, E>
where
VisitFn: for<'delegate> FnMut(Change<'delegate, 'old, 'new>) -> Result<Action, E>,
E: std::error::Error + Sync + Send + 'static,
E: Into<Box<dyn std::error::Error + Sync + Send + 'static>>,
{
/// Call `visit` on an attached version of `change`.
fn emit_change(
Expand Down Expand Up @@ -240,7 +240,7 @@ where
impl<'a, 'old, 'new, VisitFn, E> gix_diff::tree::Visit for Delegate<'a, 'old, 'new, VisitFn, E>
where
VisitFn: for<'delegate> FnMut(Change<'delegate, 'old, 'new>) -> Result<Action, E>,
E: std::error::Error + Sync + Send + 'static,
E: Into<Box<dyn std::error::Error + Sync + Send + 'static>>,
{
fn pop_front_tracked_path_and_set_current(&mut self) {
self.recorder.pop_front_tracked_path_and_set_current()
Expand Down

0 comments on commit e3c5a0f

Please sign in to comment.