unread rune on skip methods
This commit is contained in:
parent
1c9a3962ec
commit
31f5aa6e52
14
reader.go
14
reader.go
@ -176,15 +176,23 @@ func (r *Reader) PeekStringUntil(f ...RuneFunc) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SkipUntil acts as StringUntil but discards the string
|
// SkipUntil acts as StringUntil but discards the string
|
||||||
|
// The rune for which that function returned false will be unread.
|
||||||
func (r *Reader) SkipUntil(f ...RuneFunc) error {
|
func (r *Reader) SkipUntil(f ...RuneFunc) error {
|
||||||
_, err := r.StringUntil(f...)
|
_, err := r.StringUntil(f...)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return r.UnreadRune()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SkipWhile acts as StringWhile but discards the string
|
// SkipWhile acts as StringWhile but discards the string.
|
||||||
|
// The rune for which that function returned false will be unread.
|
||||||
func (r *Reader) SkipWhile(f ...RuneFunc) error {
|
func (r *Reader) SkipWhile(f ...RuneFunc) error {
|
||||||
_, err := r.StringWhile(f...)
|
_, err := r.StringWhile(f...)
|
||||||
return err
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return r.UnreadRune()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExpectRune returns true if any function returns true for the next rune read from r
|
// ExpectRune returns true if any function returns true for the next rune read from r
|
||||||
|
Loading…
Reference in New Issue
Block a user