package predicate

import "github.com/gohugoio/hugo/common/predicate"

Index

Types

type P

type P[T any] func(T) bool

P is a predicate function that tests whether a value of type T satisfies some condition.

func (P[T]) And

func (p P[T]) And(ps ...P[T]) P[T]

And returns a predicate that is a short-circuiting logical AND of this and the given predicates.

func (P[T]) Filter

func (p P[T]) Filter(s []T) []T

Filter returns a new slice holding only the elements of s that satisfy p. Filter modifies the contents of the slice s and returns the modified slice, which may have a smaller length.

func (P[T]) FilterCopy

func (p P[T]) FilterCopy(s []T) []T

FilterCopy returns a new slice holding only the elements of s that satisfy p.

func (P[T]) Negate

func (p P[T]) Negate() P[T]

Negate returns a predicate that is a logical negation of this predicate.

func (P[T]) Or

func (p P[T]) Or(ps ...P[T]) P[T]

Or returns a predicate that is a short-circuiting logical OR of this and the given predicates.

Source Files

predicate.go

Version
v0.144.2 (latest)
Published
Feb 19, 2025
Platform
linux/amd64
Last checked
13 hours ago

Tools for package owners.