Start removing the Send impl for App

Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-11-01 11:31:23 -07:00 committed by Nathan Sobo
parent ea7fdef417
commit 57ffa8201e
38 changed files with 506 additions and 932 deletions

View file

@ -4,7 +4,7 @@ pub(crate) use smallvec::SmallVec;
use std::{any::Any, mem};
pub trait Element<V: 'static> {
type ElementState: 'static + Send;
type ElementState: 'static;
fn id(&self) -> Option<ElementId>;
@ -97,7 +97,7 @@ impl<V, E: Element<V>> RenderedElement<V, E> {
impl<V, E> ElementObject<V> for RenderedElement<V, E>
where
E: Element<V>,
E::ElementState: 'static + Send,
E::ElementState: 'static,
{
fn initialize(&mut self, view_state: &mut V, cx: &mut ViewContext<V>) {
let frame_state = if let Some(id) = self.element.id() {
@ -170,16 +170,14 @@ where
}
}
pub struct AnyElement<V>(Box<dyn ElementObject<V> + Send>);
unsafe impl<V> Send for AnyElement<V> {}
pub struct AnyElement<V>(Box<dyn ElementObject<V>>);
impl<V> AnyElement<V> {
pub fn new<E>(element: E) -> Self
where
V: 'static,
E: 'static + Element<V> + Send,
E::ElementState: Any + Send,
E: 'static + Element<V>,
E::ElementState: Any,
{
AnyElement(Box::new(RenderedElement::new(element)))
}