func NewHash(hasher func() hash.Hash) *HashSum {
	return &HashSum{
		functions: []func(key []byte) []byte{
			func(key []byte) []byte {
				hash := hasher()
				hash.Write(key)
				return hash.Sum(nil)
			},
		},
	}
}
NewHash creates a new *HashSum object which can be used to create HashFunc.
HashFunc object is thread safe if the hasher argument produces a new hash.Hash
each time. The produced hash.Hash is allowed to be non thread-safe.
package hashring
import (
	"fmt"
	"hash"
)
type HashSum struct {
	functions []func([]byte) []byte
}
func (r *HashSum) Use(
	hashKeyFunc func(bytes []byte) (HashKey, error),
) (HashFunc, error) {
	composed := func(bytes []byte) []byte {
		for _, f := range r.functions {
			bytes = f(bytes)
		}
		return bytes
	}
	testResult := composed([]byte("test"))
	_, err := hashKeyFunc(testResult)
	if err != nil {
		const msg = "can't use given hash.Hash with given hashKeyFunc"
		return nil, fmt.Errorf("%s: %w", msg, err)
	}
	return func(key []byte) HashKey {
		bytes := composed(key)
		hashKey, err := hashKeyFunc(bytes)
		if err != nil {
			panic(fmt.Sprintf("hashKeyFunc failure: %v", err))
		}
		return hashKey
	}, nil
}