You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray-core/common/predicate/predicate.go

40 lines
626 B

package predicate
type Predicate func() bool
8 years ago
func (v Predicate) And(predicate Predicate) Predicate {
return All(v, predicate)
}
8 years ago
func (v Predicate) Or(predicate Predicate) Predicate {
return Any(v, predicate)
}
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
}
}
8 years ago
func Not(predicate Predicate) Predicate {
return func() bool {
return !predicate()
}
}