Introduce explicit image::allocate API

This commit is contained in:
Héctor Ramón Jiménez 2025-10-25 00:07:13 +02:00
parent 6fa54f7f6b
commit 23039e758e
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
15 changed files with 355 additions and 51 deletions

View file

@ -379,14 +379,16 @@ impl<T, E> Task<Result<T, E>> {
/// The success value is provided to the closure to create the subsequent [`Task`].
pub fn and_then<A>(
self,
f: impl Fn(T) -> Task<A> + MaybeSend + 'static,
) -> Task<A>
f: impl Fn(T) -> Task<Result<A, E>> + MaybeSend + 'static,
) -> Task<Result<A, E>>
where
T: MaybeSend + 'static,
E: MaybeSend + 'static,
A: MaybeSend + 'static,
{
self.then(move |option| option.map_or_else(|_| Task::none(), &f))
self.then(move |result| {
result.map_or_else(|error| Task::done(Err(error)), &f)
})
}
}