Skip to content

Commit

Permalink
Fix clippy::unused_async
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Sep 20, 2023
1 parent f8f1a86 commit 432d9f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
3 changes: 2 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down
8 changes: 6 additions & 2 deletions examples/screenshot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
23 changes: 14 additions & 9 deletions examples/screenshot/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 432d9f5

Please sign in to comment.