improved UnreadString

This commit is contained in:
Timon Ringwald 2022-04-19 19:58:38 +02:00
parent 094acf98ca
commit 9c3d038fcd

View File

@ -46,8 +46,8 @@ func (r *Reader) UnreadRune() error {
return nil
}
// UnreadString calls UnreadRune for each rune in str
// The actual runes are irrelevant.
// UnreadString calls UnreadRune for each rune in str + one addtional rune for the separator rune
// The actual runes in str are irrelevant.
// Only the rune count of str determines the amount of UnreadRune calls.
// The first error occured will be returned immediately.
func (r *Reader) UnreadString(str string) error {
@ -57,7 +57,7 @@ func (r *Reader) UnreadString(str string) error {
return err
}
}
return nil
return r.UnreadRune()
}
// StringWhile reads runes and calls f for each one.