tree: allow exiting empty containers
This commit is contained in:
parent
46fcb17108
commit
99f10fda4c
1 changed files with 4 additions and 2 deletions
|
@ -209,8 +209,10 @@ impl<C: std::fmt::Debug, A: std::fmt::Debug> Builder<C, A> {
|
||||||
|
|
||||||
pub(super) fn exit(&mut self) {
|
pub(super) fn exit(&mut self) {
|
||||||
self.depth -= 1;
|
self.depth -= 1;
|
||||||
if self.head.is_some() {
|
if let Some(head) = self.head.take() {
|
||||||
self.head = None;
|
if matches!(self.nodes[head.index()].kind, NodeKind::Container(..)) {
|
||||||
|
self.branch.push(head);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let last = self.branch.pop();
|
let last = self.branch.pop();
|
||||||
assert_ne!(last, None);
|
assert_ne!(last, None);
|
||||||
|
|
Loading…
Reference in a new issue