pub struct Node {
pub id: usize,
pub parent: Option<Weak<RefCell<Node>>>,
pub children: Vec<Rc<RefCell<Node>>>,
}
Expand description
Representation of a tree node, which has an id
, a Vec
of children
, as well as a Weak
reference
to its parent
Fields§
§id: usize
§parent: Option<Weak<RefCell<Node>>>
§children: Vec<Rc<RefCell<Node>>>
Implementations§
Source§impl Node
impl Node
pub fn from_adjacency_list( graph: &UnweightedAdjacencyList, root: usize, ) -> Rc<RefCell<Node>>
Trait Implementations§
Source§impl PartialEq for Node
Two nodes are identical if their id
s equal, have the same children, and have the same parent id
.
#[derive(PartialEq, Eq)]
does not work with Weak
references, so we need manual implementation.
impl PartialEq for Node
Two nodes are identical if their id
s equal, have the same children, and have the same parent id
.
#[derive(PartialEq, Eq)]
does not work with Weak
references, so we need manual implementation.
impl Eq for Node
Auto Trait Implementations§
impl Freeze for Node
impl !RefUnwindSafe for Node
impl !Send for Node
impl !Sync for Node
impl Unpin for Node
impl !UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.