fix(apb): is_empty === len()==0, new is_nothing
basically is_empty on an empty Node::Vec is true, but is_nothing on an empty Node::Vec is false
This commit is contained in:
parent
deb5fe5744
commit
d50a762f63
1 changed files with 8 additions and 2 deletions
|
@ -37,7 +37,7 @@ impl<T : super::Base> Node<T> {
|
||||||
match self {
|
match self {
|
||||||
Node::Empty | Node::Link(_) => None,
|
Node::Empty | Node::Link(_) => None,
|
||||||
Node::Object(x) => Some(x),
|
Node::Object(x) => Some(x),
|
||||||
Node::Array(v) => v.get(0),
|
Node::Array(v) => v.front(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ impl<T : super::Base> Node<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// true only if Node is empty
|
/// true only if Node is empty
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_nothing(&self) -> bool {
|
||||||
matches!(self, Node::Empty)
|
matches!(self, Node::Empty)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,12 @@ impl<T : super::Base> Node<T> {
|
||||||
matches!(self, Node::Array(_))
|
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)
|
/// returns number of contained items (links count as items for len)
|
||||||
pub fn len(&self) -> usize {
|
pub fn len(&self) -> usize {
|
||||||
match self {
|
match self {
|
||||||
|
|
Loading…
Reference in a new issue