Skip to main content

Node

Struct Node 

Source
pub struct Node<T, K> { /* private fields */ }
Expand description

A node of a tree (Node<TObject, TKey>): an item, its key, its parent and its children, as TransformToTree builds them. Nodes are held in Rc.

Deviation (DEVIATIONS.md, DynamicData): a node holds its parent weakly, so that a parent and its children (which it holds) do not keep each other alive; the parent of a node is the node of the tree that is its parent, which the tree keeps.

Implementations§

Source§

impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> Node<T, K>

Source

pub fn new(item: T, key: K) -> Rc<Self>

A node without a parent (Node(TObject, TKey)).

Source

pub fn with_parent(item: T, key: K, parent: Option<&Rc<Node<T, K>>>) -> Rc<Self>

A node of parent (Node(TObject, TKey, in Optional<Node<TObject, TKey>>)).

Source

pub fn children(&self) -> &ObservableCache<Rc<Node<T, K>>, K>

The child nodes (Children).

Source

pub fn depth(&self) -> usize

The number of ancestors of the node (Depth).

Source

pub fn is_root(&self) -> bool

Whether the node has no parent (IsRoot).

Source

pub fn item(&self) -> &T

The item (Item).

Source

pub fn key(&self) -> &K

The key of the item (Key).

Source

pub fn parent(&self) -> Option<Rc<Node<T, K>>>

The parent node (Parent).

Trait Implementations§

Source§

impl<T: Debug, K: Debug> Debug for Node<T, K>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Display + Clone + 'static, K: Eq + Hash + Clone + 'static> Display for Node<T, K>

Source§

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

ToString: the item, and the number of children when there are any.

Source§

impl<T, K: Eq> Eq for Node<T, K>

Source§

impl<T, K: Hash> Hash for Node<T, K>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

GetHashCode: the hash of the key.

1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Clone + 'static, K: Eq + Hash + Clone + 'static> IDisposable for Node<T, K>

Source§

fn dispose(&self)

Disposes the children (Dispose).

Source§

impl<T, K: PartialEq> PartialEq for Node<T, K>

Source§

fn eq(&self, other: &Self) -> bool

Nodes of the same key are equal (Equals(Node<TObject, TKey>)).

1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<T, K> !Freeze for Node<T, K>

§

impl<T, K> !RefUnwindSafe for Node<T, K>

§

impl<T, K> !Send for Node<T, K>

§

impl<T, K> !Sync for Node<T, K>

§

impl<T, K> !UnwindSafe for Node<T, K>

§

impl<T, K> Unpin for Node<T, K>
where SourceCache<Rc<Node<T, K>>, K>: Unpin, ObservableCache<Rc<Node<T, K>>, K>: Unpin, T: Unpin, K: Unpin, RefCell<Option<Weak<Node<T, K>>>>: Unpin,

§

impl<T, K> UnsafeUnpin for Node<T, K>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.