github.com/m4gshm/gollections@v0.0.13-0.20240331203319-a34a86e58a24/break/predicate/less/api.go (about)

     1  // Package less provides predicate builders
     2  package less
     3  
     4  import (
     5  	"github.com/m4gshm/gollections/break/predicate"
     6  	"golang.org/x/exp/constraints"
     7  )
     8  
     9  // Than - less.Than creates a predicate that can be used to test if a value is less than the expected
    10  func Than[T constraints.Ordered](min T) predicate.Predicate[T] {
    11  	return func(v T) (bool, error) { return v < min, nil }
    12  }
    13  
    14  // OrEq - less.OrEq creates a predicate that can be used to test if a value is less than or equal to the expected
    15  func OrEq[T constraints.Ordered](min T) predicate.Predicate[T] {
    16  	return func(v T) (bool, error) { return v <= min, nil }
    17  }