tree: allow exiting empty containers

This commit is contained in:
Noah Hellman 2023-01-26 20:16:05 +01:00
parent 46fcb17108
commit 99f10fda4c

View file

@ -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);