Source File
cond.go
Belonging Package
golang.org/x/text/runes
package runes
import (
)
func ( Set, , transform.Transformer) Transformer {
if == nil && == nil {
return Transformer{transform.Nop}
}
if == nil {
= transform.Nop
}
if == nil {
= transform.Nop
}
, := .(transform.SpanningTransformer)
if ! {
= dummySpan{}
}
, := .(transform.SpanningTransformer)
if ! {
= dummySpan{}
}
:= &cond{
tIn: ,
tNotIn: ,
f: .Contains,
}
.Reset()
return Transformer{}
}
type dummySpan struct{ transform.Transformer }
func ( dummySpan) ( []byte, bool) ( int, error) {
return 0, transform.ErrEndOfSpan
}
type cond struct {
tIn, tNotIn transform.SpanningTransformer
f func(rune) bool
check func(rune) bool // current check to perform
t transform.SpanningTransformer // current transformer to use
}
func ( *cond) () {
.check = .is
.t = .tIn
.t.Reset() // notIn will be reset on first usage.
}
func ( *cond) ( rune) bool {
if .f() {
return true
}
.check = .isNot
.t = .tNotIn
.tNotIn.Reset()
return false
}
func ( *cond) ( rune) bool {
if !.f() {
return true
}
.check = .is
.t = .tIn
.tIn.Reset()
return false
}
= +
}
return , ,
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |