Changed generic type constraint

This commit is contained in:
2023-07-18 17:14:34 +02:00
parent be04815fdb
commit 2a94dc114e
4 changed files with 7 additions and 11 deletions

View File

@ -15,7 +15,7 @@ const (
)
// Tree represents a radix tree.
type Tree[T comparable] struct {
type Tree[T any] struct {
root treeNode[T]
static map[string]T
canBeStatic [2048]bool
@ -238,12 +238,8 @@ begin:
// Bind binds all handlers to a new one provided by the callback.
func (tree *Tree[T]) Bind(transform func(T) T) {
var empty T
tree.root.each(func(node *treeNode[T]) {
if node.data != empty {
node.data = transform(node.data)
}
node.data = transform(node.data)
})
for key, value := range tree.static {