fixed StringWhile

This commit is contained in:
Timon Ringwald
2022-05-23 14:04:39 +02:00
parent 40d00d9244
commit ca6cf3d943
2 changed files with 14 additions and 1 deletions

View File

@ -84,8 +84,9 @@ func (r *Reader) UnreadString(str string) error {
func (r *Reader) StringWhile(f func(rn rune) bool) (string, error) {
s := new(strings.Builder)
var rn rune
var err error
for rn, err := r.Rune(); err == nil && f(rn); rn, err = r.Rune() {
for rn, err = r.Rune(); err == nil && f(rn); rn, err = r.Rune() {
s.WriteRune(rn)
}