Struct iced_core::widget::tree::Tree

source ·
pub struct Tree {
    pub tag: Tag,
    pub state: State,
    pub children: Vec<Tree>,
}
Expand description

A persistent state widget tree.

A Tree is normally associated with a specific widget in the widget tree.

Fields§

§tag: Tag

The tag of the Tree.

§state: State

The State of the Tree.

§children: Vec<Tree>

The children of the root widget of the Tree.

Implementations§

source§

impl Tree

source

pub fn empty() -> Self

Creates an empty, stateless Tree with no children.

source

pub fn new<'a, Message, Theme, Renderer>( widget: impl Borrow<dyn Widget<Message, Theme, Renderer> + 'a> ) -> Self
where Renderer: Renderer,

Creates a new Tree for the provided Widget.

source

pub fn diff<'a, Message, Theme, Renderer>( &mut self, new: impl Borrow<dyn Widget<Message, Theme, Renderer> + 'a> )
where Renderer: Renderer,

Reconciliates the current tree with the provided Widget.

If the tag of the Widget matches the tag of the Tree, then the Widget proceeds with the reconciliation (i.e. Widget::diff is called).

Otherwise, the whole Tree is recreated.

source

pub fn diff_children<'a, Message, Theme, Renderer>( &mut self, new_children: &[impl Borrow<dyn Widget<Message, Theme, Renderer> + 'a>] )
where Renderer: Renderer,

Reconciles the children of the tree with the provided list of widgets.

source

pub fn diff_children_custom<T>( &mut self, new_children: &[T], diff: impl Fn(&mut Tree, &T), new_state: impl Fn(&T) -> Self )

Reconciliates the children of the tree with the provided list of widgets using custom logic both for diffing and creating new widget state.

Trait Implementations§

source§

impl Debug for Tree

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Tree

§

impl !Send for Tree

§

impl !Sync for Tree

§

impl Unpin for Tree

§

impl !UnwindSafe for Tree

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<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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.