Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Merge branch 'pre-merge' into clean-up-doc-elements

Nathan Sobobcf0e3fb0566
diff --cc crates/gpui2/src/element.rs
index 08b6ec04086,cc3dc731157..02826065584
--- a/crates/gpui2/src/element.rs
+++ b/crates/gpui2/src/element.rs
@@@ -125,18 -93,10 +106,12 @@@ pub trait IntoElement: Sized
}
}
- /// A trait that all [View] types must implement.
- /// This trait tells the framework how a particular type is displayed on screen.
- /// For any type `V` implementing `Render`, you can create a `View<V>` handle, which can be used as an element in another view or as the root of a window.
pub trait Render: 'static + Sized {
- type Output: IntoElement;
-
- /// Describes how this type is displayed on screen.
- fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output;
+ fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element;
}
+/// You can derive [IntoElement] on any type that implements this trait.
+/// It is used to allow views to be expressed in terms of abstract data.
pub trait RenderOnce: 'static {
type Output: IntoElement;
diff --cc crates/gpui2/src/view.rs
index afa08f92135,41d1be852cf..b39445d5417
--- a/crates/gpui2/src/view.rs
+++ b/crates/gpui2/src/view.rs
@@@ -312,20 -312,8 +312,8 @@@ impl std::fmt::Debug for AnyWeakView
}
}
- impl<T, E> Render for T
- where
- T: 'static + FnMut(&mut WindowContext) -> E,
- E: 'static + Send + Element,
- {
- type Output = E;
-
- fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Output {
- (self)(cx)
- }
- }
-
mod any_view {
- use crate::{AnyElement, AnyView, Element, LayoutId, Render, WindowContext};
+ use crate::{AnyElement, AnyView, IntoElement, LayoutId, Render, WindowContext};
pub(crate) fn layout<V: 'static + Render>(
view: &AnyView,