浏览代码

Fixed unwrap call

AvariceLHubris 3 周之前
父节点
当前提交
e3fa04703e
共有 1 个文件被更改,包括 1 次插入5 次删除
  1. 1 5
      src/node.rs

+ 1 - 5
src/node.rs

@@ -66,11 +66,7 @@ impl Node {
     }
 
     pub fn get_character(self: &Node) -> Result<char, &str> {
-        if !self.is_leaf() {
-            return Err("This node is not a leaf node.");
-        }
-
-        Ok(self.character.unwrap())
+        self.character.ok_or("This node has no character.")
     }
 
     pub fn get_character_code(self: &Node, character: char) -> Result<BitVec, &str> {