package bufr import "git.milar.in/milarin/ds" type RuneFunc = func(rn rune) bool func IsNewLine(rn rune) bool { return rn == '\n' } func IsSpace(rn rune) bool { return rn == ' ' } func IsTab(rn rune) bool { return rn == '\t' } func IsWhitespace(rn rune) bool { return IsSpace(rn) || IsTab(rn) || IsNewLine(rn) } func And(f ...RuneFunc) RuneFunc { return func(rn rune) bool { return findFirstFalse(rn, f) } } func Or(f ...RuneFunc) RuneFunc { return func(rn rune) bool { return findFirstTrue(rn, f) } } func Not(f RuneFunc) RuneFunc { return func(rn rune) bool { return !f(rn) } } func Is(rn rune) RuneFunc { return func(r rune) bool { return rn == r } } func OneOf(runes string) RuneFunc { m := ds.NewSet[rune]() for _, rn := range runes { m.Add(rn) } return func(r rune) bool { return m.Has(r) } }