Add Node.IsLeaf

This commit is contained in:
Tom Payne 2019-04-23 22:12:31 +02:00
parent b98aa06008
commit d96905437e

View File

@ -239,6 +239,11 @@ func (n *Node) IsContainer() bool {
} }
} }
// IsLeaf returns true if 'n' is a leaf node.
func (n *Node) IsLeaf() bool {
return !n.IsContainer()
}
func (n *Node) canContain(t NodeType) bool { func (n *Node) canContain(t NodeType) bool {
if n.Type == List { if n.Type == List {
return t == Item return t == Item