Add explicit error handling to image loading

This commit is contained in:
Héctor Ramón Jiménez 2025-10-28 21:19:25 +01:00
parent 7c11ccb046
commit 867fe819c0
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
17 changed files with 357 additions and 118 deletions

View file

@ -390,6 +390,20 @@ impl<T, E> Task<Result<T, E>> {
result.map_or_else(|error| Task::done(Err(error)), &f)
})
}
/// Maps the error type of this [`Task`] to a different one using the given
/// function.
pub fn map_err<E2>(
self,
f: impl Fn(E) -> E2 + MaybeSend + 'static,
) -> Task<Result<T, E2>>
where
T: MaybeSend + 'static,
E: MaybeSend + 'static,
E2: MaybeSend + 'static,
{
self.map(move |result| result.map_err(&f))
}
}
impl<T> Default for Task<T> {