diff --git a/trie.go b/trie.go index 2799255..eb61d8d 100644 --- a/trie.go +++ b/trie.go @@ -208,6 +208,11 @@ func (n *node[T]) removeChild(r rune) { } } +// Val returns the value of the node. +func (n *node[T]) Val() T { + return n.meta +} + func findNode[T any](nd *node[T], runes []rune) *node[T] { if nd == nil { return nil diff --git a/trie_test.go b/trie_test.go index fb0f2ea..ed3f87d 100644 --- a/trie_test.go +++ b/trie_test.go @@ -46,7 +46,7 @@ func TestTrieFind(t *testing.T) { t.Fatal("Could not find node") } - if n.meta != 1 { + if n.Val() != 1 { t.Errorf("Expected 1, got: %d", n.meta) } }