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:
parent
9e4b3ce94c
commit
014e6f66bb
5 changed files with 18 additions and 14 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue