Documentation
¶
Overview ¶
stringsiter defines iterator source/collector that corresponds to std library `strings`.
Index ¶
- func Chunk(s string, n int) iter.Seq[string]
- func Collect(sizeHint int, seq iter.Seq[string]) string
- func CutNewLine(s string) (tokUntil int, skipUntil int)
- func CutUpperCase(s string) (tokUntil int, skipUntil int)
- func CutWord(s string) (tokUntil int, skipUntil int)
- func Join(sizeHint int, sep string, seq iter.Seq[string]) string
- func RuneChunk(s string, n int) iter.Seq[string]
- func SplitFunc(s string, n int, splitFn CutterFunc) iter.Seq[string]
- type CutterFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Chunk ¶
Chunk returns an iterator over non overlapping sub strings of n bytes. Sub slicing may cut in mid of utf8 sequences.
func Collect ¶
Collect concatenates all values form seq to a single string. sizeHint hints size of all values in bytes, which will be used to pre-allocate buffer.
func CutNewLine ¶
CutNewLine is used with SplitFunc. The input strings will be splitted at "\n". It also skips "\r" preceding "\n".
func CutUpperCase ¶
CutUpperCase is a split function for a SplitFunc that splits "UpperCasedWords" into "Upper" "Cased" "Words"
func CutWord ¶
CutWord is a split function for a SplitFunc that returns each space-separated word of text, with surrounding spaces deleted. It will never return an empty string. The definition of space is set by unicode.IsSpace.
func Join ¶
Join is like Collect but inserts sep between every 2 values from seq, corresponds to strings.Join.
func RuneChunk ¶
RuneChunk returns an iterator over non overlapping sub strings of n utf8 characters.
func SplitFunc ¶
SplitFunc returns an iterator over sub string of s cut by CutterFunc. When n > 0, SplitFunc cuts only n times and the returned iterator yields rest of string after n sub strings, if non empty. The sub strings from the iterator overlaps if splitFn decides so. splitFn is allowed to return negative offsets. In that case the returned iterator immediately yields rest of s and stops iteration.
Types ¶
type CutterFunc ¶
CutterFunc is used with SplitFunc to cut string from head. s[:tokUntil] is yielded through StringsSplitFunc. s[tokUntil:skipUntil] will be ignored.