gpui: Don't impl IntoElement on () (#8555)

Although it's kinda cute, rust makes it too easy to accidentally return
() from a function.

/cc @nathansobo

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-02-28 15:19:05 -07:00 committed by GitHub
parent 9e4b3ce94c
commit 014e6f66bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 18 additions and 14 deletions

View file

@ -132,8 +132,10 @@ pub trait Render: 'static + Sized {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement;
}
impl Render for () {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {}
impl Render for Empty {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
Empty
}
}
/// You can derive [`IntoElement`] on any type that implements this trait.
@ -514,9 +516,9 @@ impl IntoElement for AnyElement {
}
/// The empty element, which renders nothing.
pub type Empty = ();
pub struct Empty;
impl IntoElement for () {
impl IntoElement for Empty {
type Element = Self;
fn element_id(&self) -> Option<ElementId> {
@ -528,7 +530,7 @@ impl IntoElement for () {
}
}
impl Element for () {
impl Element for Empty {
type State = ();
fn request_layout(