go-brace/parsetowriter.go

26 lines
437 B
Go
Raw Normal View History

2023-11-22 14:52:49 +00:00
package brace
import (
"io"
"sourcecode.social/reiver/go-utf8"
)
// ParseToBytes is similar to Parse except it writes the brace-string literal as an io.Writer.
func ParseToWriter(writer io.Writer, runescanner io.RuneScanner) error {
if nil == writer {
return errNilWriter
}
fn := func(r rune) error {
_, err := utf8.WriteRune(writer, r)
if nil != err {
return err
}
return nil
}
return Parse(fn, runescanner)
}