pub trait IntoElement: Sized {
type Element: Element;
// Required method
fn into_element(self) -> Self::Element;
// Provided method
fn into_any_element(self) -> AnyElement { ... }
}Expand description
A type that can be converted into an Element, so it can be a child of another element.
ParentElement::child takes any IntoElement. Strings, Entity views and every element
implement it. Derive it with #[derive(IntoElement)] on a RenderOnce component to make the
component usable wherever an element is.
§Example
use gpui::{IntoElement, div, prelude::*};
let row = div().child("Name").child(String::from("Ada"));
let _element = row.into_element();Required Associated Types§
Sourcetype Element: Element
type Element: Element
The element type that this type converts into.
Strings convert into text elements. A RenderOnce component that derives IntoElement
converts into the element that renders it.
Required Methods§
Sourcefn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Converts self into an Element.
GPUI calls this when it needs the element. You rarely call it yourself, but it is the method to implement.
Provided Methods§
Sourcefn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
Converts self into an AnyElement, with its concrete type erased.
Use this when two branches return different element types, or a list holds mixed types.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".