summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-20 05:36:11 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-20 05:36:11 +0200
commit432d9f5f97a7312878f2f86ead13b6742638f7e8 (patch)
treec4c59d22f83bfdd7a41960cea2746caa390508fe
parentf8f1a8634402a5eb4275ff0814d03a3104fea65a (diff)
downloadiced-432d9f5f97a7312878f2f86ead13b6742638f7e8.tar.gz
iced-432d9f5f97a7312878f2f86ead13b6742638f7e8.tar.bz2
iced-432d9f5f97a7312878f2f86ead13b6742638f7e8.zip
Fix `clippy::unused_async`
-rw-r--r--.cargo/config.toml3
-rw-r--r--examples/screenshot/Cargo.toml8
-rw-r--r--examples/screenshot/src/main.rs23
3 files changed, 22 insertions, 12 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml
index 2c6b20b6..9e265aa9 100644
--- a/.cargo/config.toml
+++ b/.cargo/config.toml
@@ -8,7 +8,8 @@ clippy --workspace --no-deps -- \
-D clippy::match-wildcard-for-single-variants \
-D clippy::redundant-closure-for-method-calls \
-D clippy::filter_map_next \
- -D clippy::manual_let_else
+ -D clippy::manual_let_else \
+ -D clippy::unused_async
"""
nitpick = """
diff --git a/examples/screenshot/Cargo.toml b/examples/screenshot/Cargo.toml
index dcd77439..77b108bd 100644
--- a/examples/screenshot/Cargo.toml
+++ b/examples/screenshot/Cargo.toml
@@ -7,7 +7,11 @@ publish = false
[dependencies]
iced.workspace = true
-iced.features = ["debug", "image", "advanced"]
+iced.features = ["debug", "image", "advanced", "tokio"]
+
+image.workspace = true
+image.features = ["png"]
+
+tokio.workspace = true
-image = { workspace = true, features = ["png"]}
tracing-subscriber = "0.3" \ No newline at end of file
diff --git a/examples/screenshot/src/main.rs b/examples/screenshot/src/main.rs
index d9784dc8..fa06d3e9 100644
--- a/examples/screenshot/src/main.rs
+++ b/examples/screenshot/src/main.rs
@@ -273,15 +273,20 @@ impl Application for Example {
async fn save_to_png(screenshot: Screenshot) -> Result<String, PngError> {
let path = "screenshot.png".to_string();
- img::save_buffer(
- &path,
- &screenshot.bytes,
- screenshot.size.width,
- screenshot.size.height,
- ColorType::Rgba8,
- )
- .map(|_| path)
- .map_err(|err| PngError(format!("{err:?}")))
+
+ tokio::task::spawn_blocking(move || {
+ img::save_buffer(
+ &path,
+ &screenshot.bytes,
+ screenshot.size.width,
+ screenshot.size.height,
+ ColorType::Rgba8,
+ )
+ .map(|_| path)
+ .map_err(|err| PngError(format!("{err:?}")))
+ })
+ .await
+ .expect("Blocking task to finish")
}
#[derive(Clone, Debug)]