Skip to content

Commit e3c5a0f

Browse files
committed
fix: object::tree::diff::Platform::for_each_to_obtain_tree(callback) 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.
1 parent 03ec4e9 commit e3c5a0f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

gix/src/object/tree/diff/for_each.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'a, 'old> Platform<'a, 'old> {
4242
for_each: impl FnMut(Change<'_, 'old, 'new>) -> Result<Action, E>,
4343
) -> Result<Outcome, Error>
4444
where
45-
E: std::error::Error + Sync + Send + 'static,
45+
E: Into<Box<dyn std::error::Error + Sync + Send + 'static>>,
4646
{
4747
self.for_each_to_obtain_tree_inner(other, for_each, None)
4848
}
@@ -64,7 +64,7 @@ impl<'a, 'old> Platform<'a, 'old> {
6464
for_each: impl FnMut(Change<'_, 'old, 'new>) -> Result<Action, E>,
6565
) -> Result<Outcome, Error>
6666
where
67-
E: std::error::Error + Sync + Send + 'static,
67+
E: Into<Box<dyn std::error::Error + Sync + Send + 'static>>,
6868
{
6969
self.for_each_to_obtain_tree_inner(other, for_each, Some(resource_cache))
7070
}
@@ -76,7 +76,7 @@ impl<'a, 'old> Platform<'a, 'old> {
7676
resource_cache: Option<&mut gix_diff::blob::Platform>,
7777
) -> Result<Outcome, Error>
7878
where
79-
E: std::error::Error + Sync + Send + 'static,
79+
E: Into<Box<dyn std::error::Error + Sync + Send + 'static>>,
8080
{
8181
let repo = self.lhs.repo;
8282
let mut delegate = Delegate {
@@ -99,14 +99,14 @@ impl<'a, 'old> Platform<'a, 'old> {
9999
rewrites: delegate.process_tracked_changes(resource_cache)?,
100100
};
101101
match delegate.err {
102-
Some(err) => Err(Error::ForEach(Box::new(err))),
102+
Some(err) => Err(Error::ForEach(err.into())),
103103
None => Ok(outcome),
104104
}
105105
}
106106
Err(gix_diff::tree::changes::Error::Cancelled) => delegate
107107
.err
108108
.map_or(Err(Error::Diff(gix_diff::tree::changes::Error::Cancelled)), |err| {
109-
Err(Error::ForEach(Box::new(err)))
109+
Err(Error::ForEach(err.into()))
110110
}),
111111
Err(err) => Err(err.into()),
112112
}
@@ -126,7 +126,7 @@ struct Delegate<'a, 'old, 'new, VisitFn, E> {
126126
impl<'a, 'old, 'new, VisitFn, E> Delegate<'a, 'old, 'new, VisitFn, E>
127127
where
128128
VisitFn: for<'delegate> FnMut(Change<'delegate, 'old, 'new>) -> Result<Action, E>,
129-
E: std::error::Error + Sync + Send + 'static,
129+
E: Into<Box<dyn std::error::Error + Sync + Send + 'static>>,
130130
{
131131
/// Call `visit` on an attached version of `change`.
132132
fn emit_change(
@@ -240,7 +240,7 @@ where
240240
impl<'a, 'old, 'new, VisitFn, E> gix_diff::tree::Visit for Delegate<'a, 'old, 'new, VisitFn, E>
241241
where
242242
VisitFn: for<'delegate> FnMut(Change<'delegate, 'old, 'new>) -> Result<Action, E>,
243-
E: std::error::Error + Sync + Send + 'static,
243+
E: Into<Box<dyn std::error::Error + Sync + Send + 'static>>,
244244
{
245245
fn pop_front_tracked_path_and_set_current(&mut self) {
246246
self.recorder.pop_front_tracked_path_and_set_current()

0 commit comments

Comments
 (0)