mirror of https://github.com/v2ray/v2ray-core
32 lines
457 B
Go
32 lines
457 B
Go
package predicate
|
|
|
|
type Predicate func() bool
|
|
|
|
func All(predicates ...Predicate) Predicate {
|
|
return func() bool {
|
|
for _, p := range predicates {
|
|
if !p() {
|
|
return false
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
}
|
|
|
|
func Any(predicates ...Predicate) Predicate {
|
|
return func() bool {
|
|
for _, p := range predicates {
|
|
if p() {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
}
|
|
|
|
func Not(predicate Predicate) Predicate {
|
|
return func() bool {
|
|
return !predicate()
|
|
}
|
|
}
|