Skip to main content

Element

Enum Element 

Source
pub enum Element<'a> {
    Div(DivNode<'a>),
    Text(Text<'a>),
    Img(Img<'a>),
    RichText(&'a RichTextSpec<'a>),
    DecodedImage(&'a DecodedImageSpec),
    Vector(&'a VectorDrawSpec<'a>),
    SubView {
        id: PodId,
        generation: u16,
        resolved: Cell<Option<&'a Element<'a>>>,
    },
}
Expand description

闭合 UI 元素枚举(严格限定 4 种核心节点,彻底消除 Box<dyn Element> 虚表开销与内存碎片)。

Variants§

§

Div(DivNode<'a>)

弹性盒容器节点(64B 紧凑核心 + 按需分配在 ScratchArena 中的视觉/交互扩展)。

§

Text(Text<'a>)

文本节点。

§

Img(Img<'a>)

位图/图标掩码或过程化贴图节点(对应 DrawPayload::Sprite)。

§

RichText(&'a RichTextSpec<'a>)

行内多字重/多色/BiDi/彩色 Emoji 富文本段落(8B Arena 引用,0 字节膨胀 Element)。

§

DecodedImage(&'a DecodedImageSpec)

支持 ObjectFit / NineSlice / LRU 缓存的解码图像元素(8B Arena 引用)。

§

Vector(&'a VectorDrawSpec<'a>)

原生抗锯齿 2D 矢量画布(Polyline / Polygon / Circle / Sector,8B Arena 引用)。

§

SubView

视图边界:引用另一个常驻 Handle<T>(PodId + generation),作为局部重绘与独立布局的隔离点。

Fields

§generation: u16
§resolved: Cell<Option<&'a Element<'a>>>

Trait Implementations§

Source§

impl<'a> IntoElement<'a> for Element<'a>

Source§

fn into_element(self, _cx: &'a FrameScope) -> Element<'a>

Source§

fn into_any_element(self, cx: &'a FrameScope) -> Element<'a>

与 GPUI .into_any_element() 对应的语义别名(零堆分配返回闭合枚举 Element<'a>)。

Auto Trait Implementations§

§

impl<'a> !Freeze for Element<'a>

§

impl<'a> !RefUnwindSafe for Element<'a>

§

impl<'a> !Send for Element<'a>

§

impl<'a> !Sync for Element<'a>

§

impl<'a> !UnwindSafe for Element<'a>

§

impl<'a> Forget for Element<'a>

§

impl<'a> Move for Element<'a>

§

impl<'a> Unpin for Element<'a>

§

impl<'a> UnsafeUnpin for Element<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> FluentBuilder for T

Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self

当 condition 为 true 时执行闭包修饰自身,否则原样返回。
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self

根据 condition 在两个修饰分支之间二选一。
Source§

fn when_some<O>( self, option: Option<O>, then: impl FnOnce(Self, O) -> Self, ) -> Self

当 option 为 Some(value) 时执行闭包修饰自身,否则原样返回。
Source§

fn when_none<O>( self, option: &Option<O>, then: impl FnOnce(Self) -> Self, ) -> Self

当 option 为 None 时执行闭包修饰自身,否则原样返回。
Source§

fn apply<U>(self, f: impl FnOnce(Self) -> U) -> U

通用管道映射变换(避免与 Iterator::map / Option::map 重名)。
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.