From fd0abe18d0cfde614cc779fa0da71c4e07107b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Sun, 14 Jul 2024 22:51:52 +0200 Subject: [PATCH] Implement `application::Update` for `()` --- runtime/src/task.rs | 5 +---- src/application.rs | 10 ++++++++++ src/lib.rs | 2 -- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/runtime/src/task.rs b/runtime/src/task.rs index 72f408e036..4d75ddaaa9 100644 --- a/runtime/src/task.rs +++ b/runtime/src/task.rs @@ -283,10 +283,7 @@ impl Task> { } } -impl From<()> for Task -where - T: MaybeSend + 'static, -{ +impl From<()> for Task { fn from(_value: ()) -> Self { Self::none() } diff --git a/src/application.rs b/src/application.rs index f5e064716c..71cb6a7f03 100644 --- a/src/application.rs +++ b/src/application.rs @@ -417,6 +417,16 @@ pub trait Update { ) -> impl Into>; } +impl Update for () { + fn update( + &self, + _state: &mut State, + _message: Message, + ) -> impl Into> { + () + } +} + impl Update for T where T: Fn(&mut State, Message) -> C, diff --git a/src/lib.rs b/src/lib.rs index 7ced9a5702..138f0b04b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -345,8 +345,6 @@ pub type Result = std::result::Result<(), Error>; /// /// This is equivalent to chaining [`application()`] with [`Application::run`]. /// -/// [`program`]: program() -/// /// # Example /// ```no_run /// use iced::widget::{button, column, text, Column};