Struct bag::Node
[−]
[src]
pub struct Node<T> { pub data: T, // some fields omitted }
A generic container for a node
A Node<T>
contains the following:
- An optional identifier for a parent Node<T>
- A Vec
of identifiers for children Node<T>
s
- A publicly visible member of type T
to hold program specific data
Fields
data: T
Methods
impl<T> Node<T>
[src]
pub fn new(data: T) -> Self
[src]
Constructs a new Node<T>
Accepts the node's data of type T
. By default,
Node<T>
s have no parent, this is set on insertion
into the graph.
Example
use bag::Node; #[derive(Debug,Eq,PartialEq)] struct InternalData { name: String, id: i32 } let node = Node::new(InternalData{name: "NodeTest".to_string(), id: 42}); assert_eq!(*node.parent(), None); assert_eq!(*node.children(), Vec::new()); assert_eq!(node.data, InternalData{name: "NodeTest".to_string(), id:42});