Fix clippy::unused_async

This commit is contained in:
Héctor Ramón Jiménez 2023-09-20 05:36:11 +02:00
parent f8f1a86344
commit 432d9f5f97
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 22 additions and 12 deletions

View file

@ -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 = """

View file

@ -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"

View file

@ -273,6 +273,8 @@ impl Application for Example {
async fn save_to_png(screenshot: Screenshot) -> Result<String, PngError> {
let path = "screenshot.png".to_string();
tokio::task::spawn_blocking(move || {
img::save_buffer(
&path,
&screenshot.bytes,
@ -282,6 +284,9 @@ async fn save_to_png(screenshot: Screenshot) -> Result<String, PngError> {
)
.map(|_| path)
.map_err(|err| PngError(format!("{err:?}")))
})
.await
.expect("Blocking task to finish")
}
#[derive(Clone, Debug)]