diff --git a/src/application.rs b/src/application.rs index dfcc4c00..ef15a34a 100644 --- a/src/application.rs +++ b/src/application.rs @@ -75,9 +75,9 @@ pub use timed::timed; /// } /// ``` pub fn application( - boot: impl Boot, - update: impl Update, - view: impl for<'a> View<'a, State, Message, Theme, Renderer>, + boot: impl BootFn, + update: impl UpdateFn, + view: impl for<'a> ViewFn<'a, State, Message, Theme, Renderer>, ) -> Application> where State: 'static, @@ -103,9 +103,9 @@ where Message: program::Message + 'static, Theme: theme::Base, Renderer: program::Renderer, - Boot: self::Boot, - Update: self::Update, - View: for<'a> self::View<'a, State, Message, Theme, Renderer>, + Boot: self::BootFn, + Update: self::UpdateFn, + View: for<'a> self::ViewFn<'a, State, Message, Theme, Renderer>, { type State = State; type Message = Message; @@ -320,10 +320,10 @@ impl Application

{ } } - /// Sets the [`Title`] of the [`Application`]. + /// Sets the title of the [`Application`]. pub fn title( self, - title: impl Title, + title: impl TitleFn, ) -> Application< impl Program, > { @@ -425,12 +425,12 @@ impl Application

{ /// In practice, this means that [`application`] can both take /// simple functions like `State::default` and more advanced ones /// that return a [`Task`]. -pub trait Boot { +pub trait BootFn { /// Initializes the [`Application`] state. fn boot(&self) -> (State, Task); } -impl Boot for T +impl BootFn for T where T: Fn() -> C, C: IntoBoot, @@ -464,18 +464,18 @@ impl IntoBoot for (State, Task) { /// any closure `Fn(&State) -> String`. /// /// This trait allows the [`application`] builder to take any of them. -pub trait Title { +pub trait TitleFn { /// Produces the title of the [`Application`]. fn title(&self, state: &State) -> String; } -impl Title for &'static str { +impl TitleFn for &'static str { fn title(&self, _state: &State) -> String { self.to_string() } } -impl Title for T +impl TitleFn for T where T: Fn(&State) -> String, { @@ -488,18 +488,18 @@ where /// /// This trait allows the [`application`] builder to take any closure that /// returns any `Into>`. -pub trait Update { +pub trait UpdateFn { /// Processes the message and updates the state of the [`Application`]. fn update(&self, state: &mut State, message: Message) -> Task; } -impl Update for () { +impl UpdateFn for () { fn update(&self, _state: &mut State, _message: Message) -> Task { Task::none() } } -impl Update for T +impl UpdateFn for T where T: Fn(&mut State, Message) -> C, C: Into>, @@ -513,13 +513,13 @@ where /// /// This trait allows the [`application`] builder to take any closure that /// returns any `Into>`. -pub trait View<'a, State, Message, Theme, Renderer> { +pub trait ViewFn<'a, State, Message, Theme, Renderer> { /// Produces the widget of the [`Application`]. fn view(&self, state: &'a State) -> Element<'a, Message, Theme, Renderer>; } impl<'a, T, State, Message, Theme, Renderer, Widget> - View<'a, State, Message, Theme, Renderer> for T + ViewFn<'a, State, Message, Theme, Renderer> for T where T: Fn(&'a State) -> Widget, State: 'static, diff --git a/src/application/timed.rs b/src/application/timed.rs index 2aaf40f3..32b2f100 100644 --- a/src/application/timed.rs +++ b/src/application/timed.rs @@ -1,5 +1,5 @@ //! An [`Application`] that receives an [`Instant`] in update logic. -use crate::application::{Application, Boot, View}; +use crate::application::{Application, BootFn, ViewFn}; use crate::program; use crate::theme; use crate::time::Instant; @@ -20,10 +20,10 @@ use iced_debug as debug; /// /// [`comet`]: https://github.com/iced-rs/comet pub fn timed( - boot: impl Boot, - update: impl Update, + boot: impl BootFn, + update: impl UpdateFn, subscription: impl Fn(&State) -> Subscription, - view: impl for<'a> View<'a, State, Message, Theme, Renderer>, + view: impl for<'a> ViewFn<'a, State, Message, Theme, Renderer>, ) -> Application< impl Program, > @@ -71,10 +71,10 @@ where Message: program::Message + 'static, Theme: theme::Base + 'static, Renderer: program::Renderer + 'static, - Boot: self::Boot, - Update: self::Update, + Boot: self::BootFn, + Update: self::UpdateFn, Subscription: Fn(&State) -> self::Subscription, - View: for<'a> self::View<'a, State, Message, Theme, Renderer>, + View: for<'a> self::ViewFn<'a, State, Message, Theme, Renderer>, { type State = State; type Message = (Message, Instant); @@ -148,9 +148,9 @@ where /// The update logic of some timed [`Application`]. /// -/// This is like [`application::Update`](super::Update), +/// This is like [`application::UpdateFn`](super::UpdateFn), /// but it also takes an [`Instant`]. -pub trait Update { +pub trait UpdateFn { /// Processes the message and updates the state of the [`Application`]. fn update( &self, @@ -160,7 +160,7 @@ pub trait Update { ) -> impl Into>; } -impl Update for () { +impl UpdateFn for () { fn update( &self, _state: &mut State, @@ -170,7 +170,7 @@ impl Update for () { } } -impl Update for T +impl UpdateFn for T where T: Fn(&mut State, Message, Instant) -> C, C: Into>, diff --git a/src/daemon.rs b/src/daemon.rs index 1e4143db..08a7d939 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -23,9 +23,9 @@ use std::borrow::Cow; /// /// [`exit`]: crate::exit pub fn daemon( - boot: impl application::Boot, - update: impl application::Update, - view: impl for<'a> View<'a, State, Message, Theme, Renderer>, + boot: impl application::BootFn, + update: impl application::UpdateFn, + view: impl for<'a> ViewFn<'a, State, Message, Theme, Renderer>, ) -> Daemon> where State: 'static, @@ -51,9 +51,9 @@ where Message: program::Message + 'static, Theme: theme::Base, Renderer: program::Renderer, - Boot: application::Boot, - Update: application::Update, - View: for<'a> self::View<'a, State, Message, Theme, Renderer>, + Boot: application::BootFn, + Update: application::UpdateFn, + View: for<'a> self::ViewFn<'a, State, Message, Theme, Renderer>, { type State = State; type Message = Message; @@ -171,10 +171,10 @@ impl Daemon

{ self } - /// Sets the [`Title`] of the [`Daemon`]. + /// Sets the title of the [`Daemon`]. pub fn title( self, - title: impl Title, + title: impl TitleFn, ) -> Daemon< impl Program, > { @@ -268,18 +268,18 @@ impl Daemon

{ /// any closure `Fn(&State, window::Id) -> String`. /// /// This trait allows the [`daemon`] builder to take any of them. -pub trait Title { +pub trait TitleFn { /// Produces the title of the [`Daemon`]. fn title(&self, state: &State, window: window::Id) -> String; } -impl Title for &'static str { +impl TitleFn for &'static str { fn title(&self, _state: &State, _window: window::Id) -> String { self.to_string() } } -impl Title for T +impl TitleFn for T where T: Fn(&State, window::Id) -> String, { @@ -292,7 +292,7 @@ where /// /// This trait allows the [`daemon`] builder to take any closure that /// returns any `Into>`. -pub trait View<'a, State, Message, Theme, Renderer> { +pub trait ViewFn<'a, State, Message, Theme, Renderer> { /// Produces the widget of the [`Daemon`]. fn view( &self, @@ -302,7 +302,7 @@ pub trait View<'a, State, Message, Theme, Renderer> { } impl<'a, T, State, Message, Theme, Renderer, Widget> - View<'a, State, Message, Theme, Renderer> for T + ViewFn<'a, State, Message, Theme, Renderer> for T where T: Fn(&'a State, window::Id) -> Widget, State: 'static, diff --git a/src/lib.rs b/src/lib.rs index b0b2bb8d..4ced8d30 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -691,8 +691,8 @@ pub type Result = std::result::Result<(), Error>; /// } /// ``` pub fn run( - update: impl application::Update + 'static, - view: impl for<'a> application::View<'a, State, Message, Theme, Renderer> + update: impl application::UpdateFn + 'static, + view: impl for<'a> application::ViewFn<'a, State, Message, Theme, Renderer> + 'static, ) -> Result where