diff --git a/reader.go b/reader.go index 7329593..aef8bcf 100644 --- a/reader.go +++ b/reader.go @@ -176,15 +176,23 @@ func (r *Reader) PeekStringUntil(f ...RuneFunc) (string, error) { } // 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 { _, 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 { _, 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