* memory: add `Send + Sync` reqirement, fix #337 * Update egui/src/memory.rs Co-authored-by: Lucien Greathouse <me@lpghatguy.com> Co-authored-by: Lucien Greathouse <me@lpghatguy.com>
This commit is contained in:
parent
02a62d1986
commit
101eed0d67
|
|
@ -3,8 +3,8 @@ use std::fmt;
|
|||
|
||||
/// Like [`std::any::Any`], but also implements `Clone`.
|
||||
pub(crate) struct AnyMapElement {
|
||||
value: Box<dyn Any + 'static>,
|
||||
clone_fn: fn(&Box<dyn Any + 'static>) -> Box<dyn Any + 'static>,
|
||||
value: Box<dyn Any + 'static + Send + Sync>,
|
||||
clone_fn: fn(&Box<dyn Any + 'static + Send + Sync>) -> Box<dyn Any + 'static + Send + Sync>,
|
||||
}
|
||||
|
||||
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<T: 'static + Any + Clone> AnyMapTrait for T {}
|
||||
impl<T: 'static + Any + Clone + Send + Sync> AnyMapTrait for T {}
|
||||
|
||||
impl AnyMapElement {
|
||||
pub(crate) fn new<T: AnyMapTrait>(t: T) -> Self {
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ pub(crate) struct AnyMapElement(AnyMapElementInner);
|
|||
|
||||
enum AnyMapElementInner {
|
||||
Deserialized {
|
||||
value: Box<dyn Any + 'static>,
|
||||
clone_fn: fn(&Box<dyn Any + 'static>) -> Box<dyn Any + 'static>,
|
||||
value: Box<dyn Any + 'static + Send + Sync>,
|
||||
clone_fn: fn(&Box<dyn Any + 'static + Send + Sync>) -> Box<dyn Any + 'static + Send + Sync>,
|
||||
|
||||
serialize_fn: fn(&Box<dyn Any + 'static>) -> Result<String, ron::Error>,
|
||||
serialize_fn: fn(&Box<dyn Any + 'static + Send + Sync>) -> Result<String, ron::Error>,
|
||||
},
|
||||
Serialized(String, TypeId),
|
||||
}
|
||||
|
|
@ -84,8 +84,14 @@ impl Clone for AnyMapElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait AnyMapTrait: 'static + Any + Clone + Serialize + for<'a> Deserialize<'a> {}
|
||||
impl<T: 'static + Any + Clone + Serialize + for<'a> Deserialize<'a>> AnyMapTrait for T {}
|
||||
pub trait AnyMapTrait:
|
||||
'static + Any + Clone + Serialize + for<'a> Deserialize<'a> + Send + Sync
|
||||
{
|
||||
}
|
||||
impl<T: 'static + Any + Clone + Serialize + for<'a> Deserialize<'a> + Send + Sync> AnyMapTrait
|
||||
for T
|
||||
{
|
||||
}
|
||||
|
||||
impl AnyMapElement {
|
||||
pub(crate) fn new<T: AnyMapTrait>(t: T) -> Self {
|
||||
|
|
|
|||
|
|
@ -500,3 +500,12 @@ impl Areas {
|
|||
wants_to_be_on_top.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn memory_impl_send_sync() {
|
||||
fn assert_send_sync<T: Send + Sync>() {}
|
||||
assert_send_sync::<Memory>();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue