Added SplitFunc helper type

This commit adds the SplitFunc helper type which has a function
signature matching that of ArgsIndexer and SplitIndexer. Implementations
can use this type to provide pluggable splitters.
This commit is contained in:
diamondburned 2020-10-14 18:26:49 -07:00
parent 289eda1c25
commit 10549e49e1
1 changed files with 9 additions and 0 deletions

View File

@ -4,6 +4,15 @@ package split
import "unicode/utf8"
// SplitFunc is the type that describes the two splitter functions, SpaceIndexed
// and ArgsIndexed.
type SplitFunc = func(text string, offset int64) ([]string, int64)
var (
_ SplitFunc = SpaceIndexed
_ SplitFunc = ArgsIndexed
)
// just helper functions here
var asciiSpace = [256]uint8{'\t': 1, '\n': 1, '\v': 1, '\f': 1, '\r': 1, ' ': 1}