mirror of
https://github.com/golang/go
synced 2024-11-16 20:44:52 -07:00
strings: complete documentation of strings.Reader
There is no documentation on a number of methods of the strings.Reader
struct, so this change adds documentation referring to the relevant
io.* interfaces implemented. This is consistent with pre-existing
documentation in this struct.
Fixes #40381
Change-Id: I3dec65ecafca5b79d85d30a676d297e5ee9ab47e
GitHub-Last-Rev: f42429946a
GitHub-Pull-Request: golang/go#40654
Reviewed-on: https://go-review.googlesource.com/c/go/+/247523
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
f588974a52
commit
01efc9a3c5
@ -35,6 +35,7 @@ func (r *Reader) Len() int {
|
|||||||
// to any other method.
|
// to any other method.
|
||||||
func (r *Reader) Size() int64 { return int64(len(r.s)) }
|
func (r *Reader) Size() int64 { return int64(len(r.s)) }
|
||||||
|
|
||||||
|
// Read implements the io.Reader interface.
|
||||||
func (r *Reader) Read(b []byte) (n int, err error) {
|
func (r *Reader) Read(b []byte) (n int, err error) {
|
||||||
if r.i >= int64(len(r.s)) {
|
if r.i >= int64(len(r.s)) {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
@ -45,6 +46,7 @@ func (r *Reader) Read(b []byte) (n int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadAt implements the io.ReaderAt interface.
|
||||||
func (r *Reader) ReadAt(b []byte, off int64) (n int, err error) {
|
func (r *Reader) ReadAt(b []byte, off int64) (n int, err error) {
|
||||||
// cannot modify state - see io.ReaderAt
|
// cannot modify state - see io.ReaderAt
|
||||||
if off < 0 {
|
if off < 0 {
|
||||||
@ -60,6 +62,7 @@ func (r *Reader) ReadAt(b []byte, off int64) (n int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadByte implements the io.ByteReader interface.
|
||||||
func (r *Reader) ReadByte() (byte, error) {
|
func (r *Reader) ReadByte() (byte, error) {
|
||||||
r.prevRune = -1
|
r.prevRune = -1
|
||||||
if r.i >= int64(len(r.s)) {
|
if r.i >= int64(len(r.s)) {
|
||||||
@ -70,6 +73,7 @@ func (r *Reader) ReadByte() (byte, error) {
|
|||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnreadByte implements the io.ByteScanner interface.
|
||||||
func (r *Reader) UnreadByte() error {
|
func (r *Reader) UnreadByte() error {
|
||||||
if r.i <= 0 {
|
if r.i <= 0 {
|
||||||
return errors.New("strings.Reader.UnreadByte: at beginning of string")
|
return errors.New("strings.Reader.UnreadByte: at beginning of string")
|
||||||
@ -79,6 +83,7 @@ func (r *Reader) UnreadByte() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReadRune implements the io.RuneReader interface.
|
||||||
func (r *Reader) ReadRune() (ch rune, size int, err error) {
|
func (r *Reader) ReadRune() (ch rune, size int, err error) {
|
||||||
if r.i >= int64(len(r.s)) {
|
if r.i >= int64(len(r.s)) {
|
||||||
r.prevRune = -1
|
r.prevRune = -1
|
||||||
@ -94,6 +99,7 @@ func (r *Reader) ReadRune() (ch rune, size int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnreadRune implements the io.RuneScanner interface.
|
||||||
func (r *Reader) UnreadRune() error {
|
func (r *Reader) UnreadRune() error {
|
||||||
if r.i <= 0 {
|
if r.i <= 0 {
|
||||||
return errors.New("strings.Reader.UnreadRune: at beginning of string")
|
return errors.New("strings.Reader.UnreadRune: at beginning of string")
|
||||||
|
Loading…
Reference in New Issue
Block a user