diff --git a/egui/src/any/element.rs b/egui/src/any/element.rs index 9e41f715..a5af4e8b 100644 --- a/egui/src/any/element.rs +++ b/egui/src/any/element.rs @@ -3,8 +3,8 @@ use std::fmt; /// Like [`std::any::Any`], but also implements `Clone`. pub(crate) struct AnyMapElement { - value: Box, - clone_fn: fn(&Box) -> Box, + value: Box, + clone_fn: fn(&Box) -> Box, } impl fmt::Debug for AnyMapElement { @@ -24,9 +24,9 @@ impl Clone for AnyMapElement { } } -pub trait AnyMapTrait: 'static + Any + Clone {} +pub trait AnyMapTrait: 'static + Any + Clone + Send + Sync {} -impl AnyMapTrait for T {} +impl AnyMapTrait for T {} impl AnyMapElement { pub(crate) fn new(t: T) -> Self { diff --git a/egui/src/any/serializable/element.rs b/egui/src/any/serializable/element.rs index eb980c25..ef64c5bb 100644 --- a/egui/src/any/serializable/element.rs +++ b/egui/src/any/serializable/element.rs @@ -8,10 +8,10 @@ pub(crate) struct AnyMapElement(AnyMapElementInner); enum AnyMapElementInner { Deserialized { - value: Box, - clone_fn: fn(&Box) -> Box, + value: Box, + clone_fn: fn(&Box) -> Box, - serialize_fn: fn(&Box) -> Result, + serialize_fn: fn(&Box) -> Result, }, Serialized(String, TypeId), } @@ -84,8 +84,14 @@ impl Clone for AnyMapElement { } } -pub trait AnyMapTrait: 'static + Any + Clone + Serialize + for<'a> Deserialize<'a> {} -impl Deserialize<'a>> AnyMapTrait for T {} +pub trait AnyMapTrait: + 'static + Any + Clone + Serialize + for<'a> Deserialize<'a> + Send + Sync +{ +} +impl Deserialize<'a> + Send + Sync> AnyMapTrait + for T +{ +} impl AnyMapElement { pub(crate) fn new(t: T) -> Self { diff --git a/egui/src/memory.rs b/egui/src/memory.rs index 608b0b0f..a0b9590f 100644 --- a/egui/src/memory.rs +++ b/egui/src/memory.rs @@ -500,3 +500,12 @@ impl Areas { wants_to_be_on_top.clear(); } } + +// ---------------------------------------------------------------------------- + +#[cfg(test)] +#[test] +fn memory_impl_send_sync() { + fn assert_send_sync() {} + assert_send_sync::(); +}