diff --git a/apb/src/node.rs b/apb/src/node.rs index fa1c7d70..b79bd79f 100644 --- a/apb/src/node.rs +++ b/apb/src/node.rs @@ -37,7 +37,7 @@ impl Node { match self { Node::Empty | Node::Link(_) => None, Node::Object(x) => Some(x), - Node::Array(v) => v.get(0), + Node::Array(v) => v.front(), } } @@ -51,7 +51,7 @@ impl Node { } /// true only if Node is empty - pub fn is_empty(&self) -> bool { + pub fn is_nothing(&self) -> bool { matches!(self, Node::Empty) } @@ -70,6 +70,12 @@ impl Node { matches!(self, Node::Array(_)) } + /// true only if Node is empty + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + + /// returns number of contained items (links count as items for len) pub fn len(&self) -> usize { match self {