From 32fd8dadda6636b11d4a1d9f59b467e57b3706a8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 18 Mar 2022 22:13:52 +0700 Subject: Reintroduce generic `Message` type for `canvas::Program` As it is useful to make the `Message` completely free in many implementations. --- graphics/src/widget/canvas/program.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'graphics/src/widget/canvas/program.rs') diff --git a/graphics/src/widget/canvas/program.rs b/graphics/src/widget/canvas/program.rs index f8b9ff2b..85a2f67b 100644 --- a/graphics/src/widget/canvas/program.rs +++ b/graphics/src/widget/canvas/program.rs @@ -8,10 +8,7 @@ use iced_native::{mouse, Rectangle}; /// application. /// /// [`Canvas`]: crate::widget::Canvas -pub trait Program { - /// The [`Message`] produced by the [`Program`]. - type Message; - +pub trait Program { /// Updates the state of the [`Program`]. /// /// When a [`Program`] is used in a [`Canvas`], the runtime will call this @@ -28,7 +25,7 @@ pub trait Program { _event: Event, _bounds: Rectangle, _cursor: Cursor, - ) -> (event::Status, Option) { + ) -> (event::Status, Option) { (event::Status::Ignored, None) } @@ -56,18 +53,16 @@ pub trait Program { } } -impl Program for &mut T +impl Program for &mut T where - T: Program, + T: Program, { - type Message = T::Message; - fn update( &mut self, event: Event, bounds: Rectangle, cursor: Cursor, - ) -> (event::Status, Option) { + ) -> (event::Status, Option) { T::update(self, event, bounds, cursor) } -- cgit