Skip to content

Commit

Permalink
Implement application::Update for ()
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jul 14, 2024
1 parent d9a29f5 commit fd0abe1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
5 changes: 1 addition & 4 deletions runtime/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,7 @@ impl<T, E> Task<Result<T, E>> {
}
}

impl<T> From<()> for Task<T>
where
T: MaybeSend + 'static,
{
impl<T> From<()> for Task<T> {
fn from(_value: ()) -> Self {
Self::none()
}
Expand Down
10 changes: 10 additions & 0 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,16 @@ pub trait Update<State, Message> {
) -> impl Into<Task<Message>>;
}

impl<State, Message> Update<State, Message> for () {
fn update(
&self,
_state: &mut State,
_message: Message,
) -> impl Into<Task<Message>> {
()

Check failure on line 426 in src/application.rs

View workflow job for this annotation

GitHub Actions / all

unneeded unit expression

Check failure on line 426 in src/application.rs

View workflow job for this annotation

GitHub Actions / all

consider adding a `;` to the last statement for consistent formatting
}
}

impl<T, State, Message, C> Update<State, Message> for T
where
T: Fn(&mut State, Message) -> C,
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit fd0abe1

Please sign in to comment.