From 35ae548cd2adc0965e0448294fb54ee610cf5c67 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Mon, 18 Jul 2022 21:04:30 -0700 Subject: [PATCH] utf.RuneReader & utf8.RuneScanner --- README.md | 4 ++-- doc.go | 4 ++-- runereader.go | 4 ++-- runereader_test.go | 4 ++-- runescanner.go | 4 ++-- runescanner_test.go | 6 +++--- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 643d3be..b31a088 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ var reader io.Reader // ... -runeReader := utf8.NewRuneReader(reader) +runeReader := utf8.RuneReaderWrap(reader) // ... @@ -49,7 +49,7 @@ var reader io.Reader // ... -runeScanner := utf8.NewRuneScanner(reader) +runeScanner := utf8.RuneScannerWrap(reader) // ... diff --git a/doc.go b/doc.go index 754495a..6c88d5e 100644 --- a/doc.go +++ b/doc.go @@ -30,7 +30,7 @@ Example // ... - runeReader := utf8.NewRuneReader(reader) + runeReader := utf8.RuneReaderWrap(reader) // .. @@ -43,7 +43,7 @@ Example // ... - runeScanner := utf8.NewRuneScanner(reader) + runeScanner := utf8.RuneScannerWrap(reader) // ... diff --git a/runereader.go b/runereader.go index 43c2e08..0e536d1 100644 --- a/runereader.go +++ b/runereader.go @@ -9,8 +9,8 @@ type RuneReader struct { reader io.Reader } -func NewRuneReader(reader io.Reader) *RuneReader { - return &RuneReader{ +func RuneReaderWrap(reader io.Reader) RuneReader { + return RuneReader{ reader: reader, } } diff --git a/runereader_test.go b/runereader_test.go index 01b4666..bc2e983 100644 --- a/runereader_test.go +++ b/runereader_test.go @@ -295,7 +295,7 @@ func TestRuneReader(t *testing.T) { for testNumber, test := range tests { - runeReader := NewRuneReader(test.Reader) + runeReader := RuneReaderWrap(test.Reader) actualRune, actualInt, err := runeReader.ReadRune() if nil != err { @@ -563,7 +563,7 @@ func TestRuneReaders(t *testing.T) { var runeNumber int for { - runeReader := NewRuneReader(test.Reader) + runeReader := RuneReaderWrap(test.Reader) actualRune, actualInt, err := runeReader.ReadRune() if nil != err && io.EOF != err { diff --git a/runescanner.go b/runescanner.go index ac08d3c..c4fe3d2 100644 --- a/runescanner.go +++ b/runescanner.go @@ -15,8 +15,8 @@ type RuneScanner struct { peeked bool } -func NewRuneScanner(reader io.Reader) *RuneScanner { - return &RuneScanner{ +func RuneScannerWrap(reader io.Reader) RuneScanner { + return RuneScanner{ reader: reader, } } diff --git a/runescanner_test.go b/runescanner_test.go index 3f00ab5..73b3de3 100644 --- a/runescanner_test.go +++ b/runescanner_test.go @@ -295,7 +295,7 @@ func TestRuneScanner(t *testing.T) { for testNumber, test := range tests { - runeReader := NewRuneScanner(test.Reader) + runeReader := RuneScannerWrap(test.Reader) actualRune, actualInt, err := runeReader.ReadRune() if nil != err { @@ -563,7 +563,7 @@ func TestRuneScanners(t *testing.T) { var runeNumber int for { - runeReader := NewRuneScanner(test.Reader) + runeReader := RuneScannerWrap(test.Reader) actualRune, actualInt, err := runeReader.ReadRune() if nil != err && io.EOF != err { @@ -616,7 +616,7 @@ func TestRuneScannerUnread(t *testing.T) { TestLoop: for testNumber, test := range tests { - runeScanner := NewRuneScanner(test.Reader) + runeScanner := RuneScannerWrap(test.Reader) var readCount int for instructionNumber, instruction := range test.Instructions {