From 01c5004959c9b11f2580840f4553ad7d706f4564 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 11 Feb 2022 22:07:21 +0700 Subject: Allow pure widgets to borrow from `Application` data :tada: --- src/pure.rs | 3 ++- src/pure/application.rs | 4 ++-- src/pure/sandbox.rs | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/pure.rs b/src/pure.rs index 94d0d2a0..7fe2bc59 100644 --- a/src/pure.rs +++ b/src/pure.rs @@ -20,7 +20,8 @@ pub use iced_pure::{Element as _, *}; /// A generic, pure [`Widget`]. -pub type Element = iced_pure::Element; +pub type Element<'a, Message> = + iced_pure::Element<'a, Message, crate::Renderer>; mod application; mod sandbox; diff --git a/src/pure/application.rs b/src/pure/application.rs index 973af9f7..395eba9a 100644 --- a/src/pure/application.rs +++ b/src/pure/application.rs @@ -66,7 +66,7 @@ pub trait Application: Sized { /// Returns the widgets to display in the [`Application`]. /// /// These widgets can produce __messages__ based on user interaction. - fn view(&self) -> pure::Element; + fn view(&self) -> pure::Element<'_, Self::Message>; /// Returns the current [`Application`] mode. /// @@ -126,7 +126,7 @@ pub trait Application: Sized { struct Instance { application: A, - state: pure::State, + state: pure::State, } impl crate::Application for Instance diff --git a/src/pure/sandbox.rs b/src/pure/sandbox.rs index def90b6b..fbd1d7a8 100644 --- a/src/pure/sandbox.rs +++ b/src/pure/sandbox.rs @@ -32,7 +32,7 @@ pub trait Sandbox { /// Returns the widgets to display in the [`Sandbox`]. /// /// These widgets can produce __messages__ based on user interaction. - fn view(&self) -> pure::Element; + fn view(&self) -> pure::Element<'_, Self::Message>; /// Returns the background color of the [`Sandbox`]. /// @@ -101,7 +101,7 @@ where Subscription::none() } - fn view(&self) -> pure::Element { + fn view(&self) -> pure::Element<'_, T::Message> { T::view(self) } -- cgit