From 10549e49e15d59624bab8fc7b961d38c7ad7cff3 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Wed, 14 Oct 2020 18:26:49 -0700 Subject: [PATCH] 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. --- utils/split/split.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/split/split.go b/utils/split/split.go index e8bcaa4..30bb9fe 100644 --- a/utils/split/split.go +++ b/utils/split/split.go @@ -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}