collections/functions/types.go

25 lines
753 B
Go

package functions
type (
// Consumer takes an argument of type T and returns nothing.
Consumer[T any] func(T)
// Function takes an argument of type T and returns a result of type U.
Function[T, U any] func(T) U
// Predicate takes an argument of type T and returns a boolean result.
Predicate[T any] func(T) bool
// Supplier takes no argument and returns a result of type T.
Supplier[T any] func() T
// UnaryOperator takes an argument of type T and returns a result of type T.
UnaryOperator[T any] func(T) T
// BinaryOperator takes two arguments of type T and returns a result of type T.
BinaryOperator[T any] func(T, T) T
// Comparator takes two arguments of type T and returns a boolean result.
Comparator[T any] func(T, T) bool
)