not.go 333 B

1234567891011121314151617
  1. package filter
  2. import "fmt"
  3. // Not negates any filter contained within it
  4. type Not[T any] struct {
  5. Filter Filter[T]
  6. }
  7. func (n Not[T]) String() string {
  8. return fmt.Sprintf("(not %s)", n.Filter.String())
  9. }
  10. // Matches inverts the result of the child filter
  11. func (n Not[T]) Matches(that T) bool {
  12. return !n.Filter.Matches(that)
  13. }