Merge branch 'fewer-bounds' into zed2

This commit is contained in:
Nathan Sobo 2023-10-24 14:24:06 +02:00
commit 2285a35016
17 changed files with 400 additions and 361 deletions

View file

@ -361,8 +361,9 @@ pub trait StatefulInteractive: StatelessInteractive {
) -> Self
where
Self: Sized,
S: 'static + Send + Sync,
R: 'static + Fn(&mut Self::ViewState, &mut ViewContext<Self::ViewState>) -> E + Send + Sync,
S: Any + Send + Sync,
R: Fn(&mut Self::ViewState, &mut ViewContext<Self::ViewState>) -> E,
R: 'static + Send + Sync,
E: Element<ViewState = Self::ViewState>,
{
debug_assert!(
@ -388,7 +389,7 @@ pub trait StatefulInteractive: StatelessInteractive {
}
}
pub trait ElementInteraction<V: 'static + Send + Sync>: 'static + Send + Sync {
pub trait ElementInteraction<V: 'static>: 'static + Send + Sync {
fn as_stateless(&self) -> &StatelessInteraction<V>;
fn as_stateless_mut(&mut self) -> &mut StatelessInteraction<V>;
fn as_stateful(&self) -> Option<&StatefulInteraction<V>>;
@ -682,7 +683,7 @@ pub trait ElementInteraction<V: 'static + Send + Sync>: 'static + Send + Sync {
}
#[derive(Deref, DerefMut)]
pub struct StatefulInteraction<V: 'static + Send + Sync> {
pub struct StatefulInteraction<V> {
pub id: ElementId,
#[deref]
#[deref_mut]
@ -693,10 +694,7 @@ pub struct StatefulInteraction<V: 'static + Send + Sync> {
drag_listener: Option<DragListener<V>>,
}
impl<V> ElementInteraction<V> for StatefulInteraction<V>
where
V: 'static + Send + Sync,
{
impl<V: 'static> ElementInteraction<V> for StatefulInteraction<V> {
fn as_stateful(&self) -> Option<&StatefulInteraction<V>> {
Some(self)
}
@ -714,10 +712,7 @@ where
}
}
impl<V> From<ElementId> for StatefulInteraction<V>
where
V: 'static + Send + Sync,
{
impl<V> From<ElementId> for StatefulInteraction<V> {
fn from(id: ElementId) -> Self {
Self {
id,
@ -730,7 +725,7 @@ where
}
}
type DropListener<V> = dyn Fn(&mut V, AnyBox, &mut ViewContext<V>) + Send + Sync;
type DropListener<V> = dyn Fn(&mut V, AnyBox, &mut ViewContext<V>) + 'static + Send + Sync;
pub struct StatelessInteraction<V> {
pub dispatch_context: DispatchContext,
@ -746,10 +741,7 @@ pub struct StatelessInteraction<V> {
drop_listeners: SmallVec<[(TypeId, Arc<DropListener<V>>); 2]>,
}
impl<V> StatelessInteraction<V>
where
V: 'static + Send + Sync,
{
impl<V> StatelessInteraction<V> {
pub fn into_stateful(self, id: impl Into<ElementId>) -> StatefulInteraction<V> {
StatefulInteraction {
id: id.into(),
@ -841,10 +833,7 @@ impl<V> Default for StatelessInteraction<V> {
}
}
impl<V> ElementInteraction<V> for StatelessInteraction<V>
where
V: 'static + Send + Sync,
{
impl<V: 'static> ElementInteraction<V> for StatelessInteraction<V> {
fn as_stateful(&self) -> Option<&StatefulInteraction<V>> {
None
}
@ -919,9 +908,7 @@ pub struct ClickEvent {
pub struct Drag<S, R, V, E>
where
S: 'static + Send + Sync,
R: Fn(&mut V, &mut ViewContext<V>) -> E,
V: 'static + Send + Sync,
E: Element<ViewState = V>,
{
pub state: S,
@ -931,9 +918,7 @@ where
impl<S, R, V, E> Drag<S, R, V, E>
where
S: 'static + Send + Sync,
R: Fn(&mut V, &mut ViewContext<V>) -> E + Send + Sync,
V: 'static + Send + Sync,
R: Fn(&mut V, &mut ViewContext<V>) -> E,
E: Element<ViewState = V>,
{
pub fn new(state: S, render_drag_handle: R) -> Self {