Make run_with take a FnOnce

This commit is contained in:
Héctor Ramón Jiménez 2024-07-15 13:34:22 +02:00
parent 950bfc07d4
commit bdf0430880
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 5 additions and 5 deletions

View file

@ -169,7 +169,7 @@ impl<P: Program> Application<P> {
pub fn run_with<I>(self, initialize: I) -> Result
where
Self: 'static,
I: Fn() -> (P::State, Task<P::Message>) + Clone + 'static,
I: FnOnce() -> (P::State, Task<P::Message>) + 'static,
{
self.raw
.run_with(self.settings, Some(self.window), initialize)

View file

@ -119,7 +119,7 @@ impl<P: Program> Daemon<P> {
pub fn run_with<I>(self, initialize: I) -> Result
where
Self: 'static,
I: Fn() -> (P::State, Task<P::Message>) + Clone + 'static,
I: FnOnce() -> (P::State, Task<P::Message>) + 'static,
{
self.raw.run_with(self.settings, None, initialize)
}

View file

@ -92,7 +92,7 @@ pub trait Program: Sized {
) -> Result
where
Self: 'static,
I: Fn() -> (Self::State, Task<Self::Message>) + Clone + 'static,
I: FnOnce() -> (Self::State, Task<Self::Message>) + 'static,
{
use std::marker::PhantomData;
@ -102,8 +102,8 @@ pub trait Program: Sized {
_initialize: PhantomData<I>,
}
impl<P: Program, I: Fn() -> (P::State, Task<P::Message>)> shell::Program
for Instance<P, I>
impl<P: Program, I: FnOnce() -> (P::State, Task<P::Message>)>
shell::Program for Instance<P, I>
{
type Message = P::Message;
type Theme = P::Theme;