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.
This commit is contained in:
parent
4abaee8b23
commit
5df2a92f28
4 changed files with 7 additions and 4 deletions
|
|
@ -11,7 +11,7 @@ pub trait Program: Sized {
|
||||||
type Renderer: Renderer;
|
type Renderer: Renderer;
|
||||||
|
|
||||||
/// The type of __messages__ your [`Program`] will produce.
|
/// 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.
|
/// The type of [`Clipboard`] your [`Program`] will use.
|
||||||
type Clipboard: Clipboard;
|
type Clipboard: Clipboard;
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ pub trait Application: Sized {
|
||||||
type Executor: Executor;
|
type Executor: Executor;
|
||||||
|
|
||||||
/// The type of __messages__ your [`Application`] will produce.
|
/// 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`].
|
/// The data needed to initialize your [`Application`].
|
||||||
type Flags;
|
type Flags;
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ use crate::{
|
||||||
/// ```
|
/// ```
|
||||||
pub trait Sandbox {
|
pub trait Sandbox {
|
||||||
/// The type of __messages__ your [`Sandbox`] will produce.
|
/// The type of __messages__ your [`Sandbox`] will produce.
|
||||||
type Message: std::fmt::Debug + Send;
|
type Message: std::fmt::Debug + Clone + Send;
|
||||||
|
|
||||||
/// Initializes the [`Sandbox`].
|
/// Initializes the [`Sandbox`].
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,10 @@ pub fn menu<Message>(menu: &Menu<Message>) -> winit::window::Menu {
|
||||||
pub fn menu_message<Message>(
|
pub fn menu_message<Message>(
|
||||||
_menu: &Menu<Message>,
|
_menu: &Menu<Message>,
|
||||||
id: isize,
|
id: isize,
|
||||||
) -> Option<Message> {
|
) -> Option<Message>
|
||||||
|
where
|
||||||
|
Message: Clone,
|
||||||
|
{
|
||||||
println!("Menu entry activated: {}", id);
|
println!("Menu entry activated: {}", id);
|
||||||
|
|
||||||
None
|
None
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue