diff options
author | Luke Shumaker <lukeshu@datawire.io> | 2022-08-21 12:06:50 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@datawire.io> | 2022-08-21 12:06:50 -0600 |
commit | 6ba16f05e9c36d4341da4590600eb2c4221ac642 (patch) | |
tree | adccf15073073237eafc1926110fe3da46ea2aee /decode_scan.go | |
parent | fb063e2955debb9d02debf3f59de291d99017058 (diff) |
decode: Lean in to io.RuneScanner
So that it's easier to compose your own .DecodeJSON methods, since
.DecodeJSON takes an io.RuneScanner.
Diffstat (limited to 'decode_scan.go')
-rw-r--r-- | decode_scan.go | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/decode_scan.go b/decode_scan.go index fb8a6ec..eee61fc 100644 --- a/decode_scan.go +++ b/decode_scan.go @@ -28,7 +28,7 @@ type runeTypeScanner interface { // runeTypeScannerImpl ///////////////////////////////////////////////////////////////////////////// type runeTypeScannerImpl struct { - inner io.RuneReader + inner io.RuneScanner initialized bool @@ -73,9 +73,7 @@ func (sc *runeTypeScannerImpl) ReadRuneType() (rune, int, RuneType, error) { case sc.stuck: // do nothing case sc.repeat: - if _, ok := sc.inner.(io.RuneScanner); ok { - _, _, _ = sc.inner.ReadRune() - } + _, _, _ = sc.inner.ReadRune() default: var err error sc.rRune, sc.rSize, err = sc.inner.ReadRune() @@ -138,9 +136,7 @@ func (sc *runeTypeScannerImpl) UnreadRune() error { return ErrInvalidUnreadRune } sc.repeat = true - if rs, ok := sc.inner.(io.RuneScanner); ok { - _ = rs.UnreadRune() - } + _ = sc.inner.UnreadRune() return nil } |