Skip to main content

IntoElement

Trait IntoElement 

Source
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§

Source

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§

Source

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§

Source

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".

Implementations on Foreign Types§

Source§

impl IntoElement for &'static str

Source§

type Element = &'static str

Source§

fn into_element(self) -> Self::Element

Source§

impl IntoElement for Cow<'static, str>

Source§

impl IntoElement for String

Implementors§

Source§

impl IntoElement for Anchored

Source§

impl IntoElement for AnyElement

Source§

impl IntoElement for AnyView

Source§

type Element = ViewElement<AnyView>

Source§

impl IntoElement for ContainerQuery

Source§

impl IntoElement for Deferred

Source§

impl IntoElement for Div

Source§

impl IntoElement for Empty

Source§

impl IntoElement for ImageCacheElement

Source§

impl IntoElement for Img

Source§

impl IntoElement for InteractiveText

Source§

impl IntoElement for List

Source§

impl IntoElement for SharedString

Source§

impl IntoElement for StyledText

Source§

impl IntoElement for Surface

Source§

impl IntoElement for Svg

Source§

impl IntoElement for Text

Source§

impl IntoElement for UniformList

Source§

impl<E: IntoElement + 'static> IntoElement for AnimationElement<E>

Source§

impl<E: IntoElement + 'static> IntoElement for SpringAnimationElement<E>

Source§

impl<E: IntoElement> IntoElement for Stateful<E>

Source§

impl<T: 'static> IntoElement for Canvas<T>

Source§

impl<V: 'static + Render> IntoElement for Entity<V>

Source§

type Element = ViewElement<Entity<V>>