From b82c809717b4e769000c9b78efe6ea2558173488 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kevin=20Ka=C3=9Felmann?= <kevin.kasselmann@arithnea.de>
Date: Fri, 29 Jun 2018 11:08:35 +0200
Subject: [PATCH] Changed method signature

---
 src/common/succinct_tree.rs |  2 +-
 src/trees/bp_tree.rs        |  7 ++++---
 src/trees/louds_tree.rs     | 11 ++++-------
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/common/succinct_tree.rs b/src/common/succinct_tree.rs
index 74cd871..d49a35e 100644
--- a/src/common/succinct_tree.rs
+++ b/src/common/succinct_tree.rs
@@ -10,7 +10,7 @@ pub trait SuccinctTree<T, Label>: Debug {
     fn first_child(&self, index: u64) -> Result<u64, NodeError>;
     fn next_sibling(&self, index: u64) -> Result<u64, NodeError>;
     fn from_id_tree(tree: Tree<i32>) -> Result<T, EmptyTreeError>;
-    fn child_label(&self, index: u64) -> Result<Label, NodeError>;
+    fn child_label(&self, index: u64) -> Result<&Label, NodeError>;
     fn labeled_child(&self, index: u64, label: Label) -> Result<u64, NodeError>;
 
     /// Prüft ob ein Bitvector ein gültiger SuccinctTree ist, anhand des gültigen Exzesses und
diff --git a/src/trees/bp_tree.rs b/src/trees/bp_tree.rs
index 3621c4f..cecf078 100644
--- a/src/trees/bp_tree.rs
+++ b/src/trees/bp_tree.rs
@@ -138,9 +138,9 @@ impl<L> SuccinctTree<BPTree<L>, L> for BPTree<L> {
     /// # Arguments
     /// * `index` The index of the node to get the label of
     /// # Errors
-    /// * `NotANodeError` If `index` does not reference a node.
-    fn child_label(&self, index: u64) -> Result<L, NodeError> {
-        unimplemented!();
+    /// * `NoLabelError` If `index` does not reference a node with a label.
+    fn child_label(&self, index: u64) -> Result<&L, NodeError> {
+        self.labels.get(index as usize).ok_or(NodeError::NoLabelError)
     }
 
     /// Returns the child from the specified node with that label
@@ -151,6 +151,7 @@ impl<L> SuccinctTree<BPTree<L>, L> for BPTree<L> {
     /// * `NoSuchChildError` If there is no child which has this label
     fn labeled_child(&self, index: u64, label: L) -> Result<u64, NodeError> {
         unimplemented!();
+
     }
 }
 
diff --git a/src/trees/louds_tree.rs b/src/trees/louds_tree.rs
index bf6ed55..4944a70 100644
--- a/src/trees/louds_tree.rs
+++ b/src/trees/louds_tree.rs
@@ -153,7 +153,7 @@ impl<L> SuccinctTree<LOUDSTree<L>, L> for LOUDSTree<L> {
     /// * `index` The index of the node to get the label of
     /// # Errors
     /// * `NotANodeError` If `index` does not reference a node.
-    fn child_label(&self, index: u64) -> Result<L, NodeError> {
+    fn child_label(&self, index: u64) -> Result<&L, NodeError> {
         unimplemented!();
     }
 
@@ -250,7 +250,8 @@ mod tests {
         let tree: LOUDSTree<String> = LOUDSTree::from_bitvec(bitvec.clone()).unwrap();
         tree.save_to("testdata/loudstree.testdata".to_string())
             .unwrap();
-        let result: LOUDSTree<String> = LOUDSTree::from_file("testdata/loudstree.testdata".to_string()).unwrap();
+        let result: LOUDSTree<String> =
+            LOUDSTree::from_file("testdata/loudstree.testdata".to_string()).unwrap();
         assert_eq!(
             tree, result,
             "The loaded tree is not equal to the original one."
@@ -388,7 +389,6 @@ mod tests {
         assert_ne!(tree_a, tree_c)
     }
 
-
     #[test]
     fn from_id_tree() {
         let mut id_tree: Tree<i32> = TreeBuilder::new().with_node_capacity(5).build();
@@ -406,9 +406,6 @@ mod tests {
     fn from_empty_id_tree() {
         let id_tree: Tree<i32> = TreeBuilder::new().with_node_capacity(5).build();
         let tree: Result<LOUDSTree<String>, EmptyTreeError> = LOUDSTree::from_id_tree(id_tree);
-        assert_eq!(
-            tree.unwrap_err(),
-            EmptyTreeError
-        );
+        assert_eq!(tree.unwrap_err(), EmptyTreeError);
     }
 }
-- 
GitLab