Tree

Struct 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, Renderer>( widget: impl Borrow<dyn Widget<Message, Renderer> + 'a>, ) -> Self

Creates a new Tree for the provided [Element].

Source

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

Reconciliates the current tree with the provided [Element].

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

Otherwise, the whole Tree is recreated.

Source

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

Reconciliates the children of the tree with the provided list of [Element].

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 [Element] using custom logic both for diffing and creating new widget state.

Auto Trait Implementations§

§

impl Freeze for Tree

§

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>,

Source§

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>,

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.