|
@@ -1,36 +1,36 @@
|
|
|
|
|
|
-struct Nodes<T> {
|
|
|
- data: Vec<DataNode<T>>
|
|
|
+pub struct Nodes<T> {
|
|
|
+ data: Vec<Node<T>>
|
|
|
}
|
|
|
|
|
|
impl<T> Nodes<T> {
|
|
|
- fn new() -> Nodes<T> {
|
|
|
+ pub fn new() -> Nodes<T> {
|
|
|
Nodes {
|
|
|
data: Vec::new()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- fn add_node(&mut self, member: DataNode<T>) {
|
|
|
+ pub fn add_node(&mut self, member: Node<T>) {
|
|
|
self.data.push(member)
|
|
|
}
|
|
|
|
|
|
- fn is_empty(&mut self) -> bool {
|
|
|
+ pub fn is_empty(&mut self) -> bool {
|
|
|
self.data.len() == 0
|
|
|
}
|
|
|
|
|
|
- fn pop_node(&mut self) -> Option<DataNode<T>>{
|
|
|
+ pub fn pop_node(&mut self) -> Option<Node<T>>{
|
|
|
self.data.pop()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-struct DataNode<T> {
|
|
|
+pub struct Node<T> {
|
|
|
key: String,
|
|
|
value: Option<T>
|
|
|
}
|
|
|
|
|
|
-impl<T> DataNode<T> {
|
|
|
- fn new(t_key: &str, t_value: Option<T>) -> DataNode<T>{
|
|
|
- DataNode {
|
|
|
+impl<T> Node<T> {
|
|
|
+ pub fn new(t_key: &str, t_value: Option<T>) -> Node<T>{
|
|
|
+ Node {
|
|
|
key: String::from(t_key),
|
|
|
value: Option::from(t_value)
|
|
|
}
|
|
@@ -43,12 +43,12 @@ impl<T> DataNode<T> {
|
|
|
|
|
|
#[cfg(test)]
|
|
|
mod tests {
|
|
|
- use super::Nodes;
|
|
|
- use super::DataNode;
|
|
|
+ use super::*;
|
|
|
+
|
|
|
#[test]
|
|
|
fn add_node_to_nodes() {
|
|
|
let mut n: Nodes<&str> = Nodes::new();
|
|
|
- let d = DataNode::new("Key1", Option::from("Hello"));
|
|
|
+ let d = Node::new("Key1", Option::from("Hello"));
|
|
|
n.add_node(d);
|
|
|
let dd = n.pop_node();
|
|
|
assert!(dd.is_some());
|