summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-07-13 21:15:07 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-07-13 21:15:07 +0200
commit5df2a92f28be1d53d32d5b42a6645459b7d78efe (patch)
tree424a30db96af6864b4c505b5358eb9ef18b40a13
parent4abaee8b2354a666a75e4eb5ec9cc9a744936813 (diff)
downloadiced-5df2a92f28be1d53d32d5b42a6645459b7d78efe.tar.gz
iced-5df2a92f28be1d53d32d5b42a6645459b7d78efe.tar.bz2
iced-5df2a92f28be1d53d32d5b42a6645459b7d78efe.zip
Force `Application::Message` to implement `Clone`
A `Message` should represent an application event (e.g. user interactions, command results, subscription results...). Therefore, it should always consist of pure, cloneable data.
-rw-r--r--native/src/program.rs2
-rw-r--r--src/application.rs2
-rw-r--r--src/sandbox.rs2
-rw-r--r--winit/src/conversion.rs5
4 files changed, 7 insertions, 4 deletions
diff --git a/native/src/program.rs b/native/src/program.rs
index 066c29d8..75fab094 100644
--- a/native/src/program.rs
+++ b/native/src/program.rs
@@ -11,7 +11,7 @@ pub trait Program: Sized {
type Renderer: Renderer;
/// The type of __messages__ your [`Program`] will produce.
- type Message: std::fmt::Debug + Send;
+ type Message: std::fmt::Debug + Clone + Send;
/// The type of [`Clipboard`] your [`Program`] will use.
type Clipboard: Clipboard;
diff --git a/src/application.rs b/src/application.rs
index b3dae1b3..42c28f99 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -99,7 +99,7 @@ pub trait Application: Sized {
type Executor: Executor;
/// The type of __messages__ your [`Application`] will produce.
- type Message: std::fmt::Debug + Send;
+ type Message: std::fmt::Debug + Clone + Send;
/// The data needed to initialize your [`Application`].
type Flags;
diff --git a/src/sandbox.rs b/src/sandbox.rs
index 10b05a92..cb3cf624 100644
--- a/src/sandbox.rs
+++ b/src/sandbox.rs
@@ -88,7 +88,7 @@ use crate::{
/// ```
pub trait Sandbox {
/// The type of __messages__ your [`Sandbox`] will produce.
- type Message: std::fmt::Debug + Send;
+ type Message: std::fmt::Debug + Clone + Send;
/// Initializes the [`Sandbox`].
///
diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs
index 75419006..687a037e 100644
--- a/winit/src/conversion.rs
+++ b/winit/src/conversion.rs
@@ -223,7 +223,10 @@ pub fn menu<Message>(menu: &Menu<Message>) -> winit::window::Menu {
pub fn menu_message<Message>(
_menu: &Menu<Message>,
id: isize,
-) -> Option<Message> {
+) -> Option<Message>
+where
+ Message: Clone,
+{
println!("Menu entry activated: {}", id);
None