summaryrefslogtreecommitdiffstats
path: root/graphics/src/widget/pure/canvas
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-03-18 22:13:52 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-03-18 22:13:52 +0700
commit32fd8dadda6636b11d4a1d9f59b467e57b3706a8 (patch)
tree6acb0c0d0a14c032939412f8d177dc08c5fd75aa /graphics/src/widget/pure/canvas
parentd7100fd2597da82d97eaf196d50573ea64f3f8ff (diff)
downloadiced-32fd8dadda6636b11d4a1d9f59b467e57b3706a8.tar.gz
iced-32fd8dadda6636b11d4a1d9f59b467e57b3706a8.tar.bz2
iced-32fd8dadda6636b11d4a1d9f59b467e57b3706a8.zip
Reintroduce generic `Message` type for `canvas::Program`
As it is useful to make the `Message` completely free in many implementations.
Diffstat (limited to 'graphics/src/widget/pure/canvas')
-rw-r--r--graphics/src/widget/pure/canvas/program.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/graphics/src/widget/pure/canvas/program.rs b/graphics/src/widget/pure/canvas/program.rs
index cb52910d..ee74c27f 100644
--- a/graphics/src/widget/pure/canvas/program.rs
+++ b/graphics/src/widget/pure/canvas/program.rs
@@ -9,10 +9,7 @@ use crate::Rectangle;
/// application.
///
/// [`Canvas`]: crate::widget::Canvas
-pub trait Program {
- /// The [`Message`] produced by the [`Program`].
- type Message;
-
+pub trait Program<Message> {
/// The internal [`State`] mutated by the [`Program`].
type State: Default + 'static;
@@ -33,7 +30,7 @@ pub trait Program {
_event: Event,
_bounds: Rectangle,
_cursor: Cursor,
- ) -> (event::Status, Option<Self::Message>) {
+ ) -> (event::Status, Option<Message>) {
(event::Status::Ignored, None)
}
@@ -67,11 +64,10 @@ pub trait Program {
}
}
-impl<T> Program for &T
+impl<Message, T> Program<Message> for &T
where
- T: Program,
+ T: Program<Message>,
{
- type Message = T::Message;
type State = T::State;
fn update(
@@ -80,7 +76,7 @@ where
event: Event,
bounds: Rectangle,
cursor: Cursor,
- ) -> (event::Status, Option<Self::Message>) {
+ ) -> (event::Status, Option<Message>) {
T::update(self, state, event, bounds, cursor)
}