소스 검색

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> {