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(seq iter.Seq[string]) string
- func CollectHinted(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(sep string, seq iter.Seq[string]) string
- func JoinHinted(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. If size of all value over seq
func CollectHinted ¶ added in v0.0.18
CollectHinted is like Collect but can hint its internal buffer size to reduce allocation per call.
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, which corresponds to strings.Join.
func JoinHinted ¶ added in v0.0.18
JoinHinted is like Join but can hint its internal buffer size to reduce allocation per call.
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.