From 15230cbee361496c39be9197af408a1024dddfed Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Fri, 23 May 2025 12:16:29 -0700 Subject: [PATCH 1/3] implement Debug for Task --- runtime/src/task.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/runtime/src/task.rs b/runtime/src/task.rs index 756f592b..f6cc961d 100644 --- a/runtime/src/task.rs +++ b/runtime/src/task.rs @@ -17,7 +17,6 @@ pub use sipper::{Never, Sender, Sipper, Straw, sipper, stream}; /// A set of concurrent actions to be performed by the iced runtime. /// /// A [`Task`] _may_ produce a bunch of values of type `T`. -#[allow(missing_debug_implementations)] #[must_use = "`Task` must be returned to the runtime to take effect; normally in your `update` or `new` functions."] pub struct Task { stream: Option>>, @@ -278,6 +277,17 @@ impl Task { } } +impl std::fmt::Debug for Task { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + f, + "Task<{}>, units={}", + std::any::type_name::(), + self.units + ) + } +} + /// A handle to a [`Task`] that can be used for aborting it. #[derive(Debug, Clone)] pub struct Handle { From 7eb371729be57f8c3e7d3c519651066892f84964 Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Tue, 27 May 2025 08:40:34 -0700 Subject: [PATCH 2/3] Remove unnecessary bound --- runtime/src/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/task.rs b/runtime/src/task.rs index f6cc961d..a932a162 100644 --- a/runtime/src/task.rs +++ b/runtime/src/task.rs @@ -277,7 +277,7 @@ impl Task { } } -impl std::fmt::Debug for Task { +impl std::fmt::Debug for Task { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!( f, From 8efda5e68835dfc192f60143b16e5c82dab37c5f Mon Sep 17 00:00:00 2001 From: Craig Watson Date: Tue, 3 Jun 2025 09:28:15 -0700 Subject: [PATCH 3/3] use `debug_struct` instead of `write!` --- runtime/src/task.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/runtime/src/task.rs b/runtime/src/task.rs index a932a162..731c0be8 100644 --- a/runtime/src/task.rs +++ b/runtime/src/task.rs @@ -279,12 +279,9 @@ impl Task { impl std::fmt::Debug for Task { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "Task<{}>, units={}", - std::any::type_name::(), - self.units - ) + f.debug_struct(&format!("Task<{}>", std::any::type_name::())) + .field("units", &self.units) + .finish() } }