From 9f21eae1528fa414adbfb987ce4c851fa58326fe Mon Sep 17 00:00:00 2001
From: Héctor Ramón Jiménez <hector@hecrj.dev>
Date: Tue, 11 Feb 2025 02:34:10 +0100
Subject: Introduce `Task::map_with`

---
 examples/download_progress/src/main.rs |  2 +-
 examples/gallery/src/main.rs           | 18 ++++++++----------
 2 files changed, 9 insertions(+), 11 deletions(-)

(limited to 'examples')

diff --git a/examples/download_progress/src/main.rs b/examples/download_progress/src/main.rs
index 8f59f1dc..cc7a7800 100644
--- a/examples/download_progress/src/main.rs
+++ b/examples/download_progress/src/main.rs
@@ -52,7 +52,7 @@ impl Example {
 
                 let task = download.start();
 
-                task.map(move |update| Message::DownloadUpdated(index, update))
+                task.map_with(index, Message::DownloadUpdated)
             }
             Message::DownloadUpdated(id, update) => {
                 if let Some(download) =
diff --git a/examples/gallery/src/main.rs b/examples/gallery/src/main.rs
index ab22679d..441ad924 100644
--- a/examples/gallery/src/main.rs
+++ b/examples/gallery/src/main.rs
@@ -94,17 +94,15 @@ impl Gallery {
                     return Task::none();
                 };
 
-                Task::batch(vec![
-                    Task::perform(
+                Task::batch([
+                    Task::future(
                         image.clone().blurhash(Preview::WIDTH, Preview::HEIGHT),
-                        move |result| Message::BlurhashDecoded(id, result),
-                    ),
-                    Task::perform(
-                        image.download(Size::Thumbnail {
-                            width: Preview::WIDTH,
-                        }),
-                        move |result| Message::ThumbnailDownloaded(id, result),
-                    ),
+                    )
+                    .map_with(id, Message::BlurhashDecoded),
+                    Task::future(image.download(Size::Thumbnail {
+                        width: Preview::WIDTH,
+                    }))
+                    .map_with(id, Message::ThumbnailDownloaded),
                 ])
             }
             Message::ImageDownloaded(Ok(rgba)) => {
-- 
cgit