Skip to content

proposal: io: add RuneWriter interface #71027

Open
@mateusz834

Description

@mateusz834

Proposal Details

Today i was surprised that io does not define a RuneWriter interface, it think that we should add one, considering that it is implemented by types in the std, also we already have a io.RuneReader interface and io.ByteWriter/io.ByteReader.

(*strings.Builder).WriteRune
(*bytes.Buffer).WriteRune
(*bufio.Writer).WriteRune

Proposed API:

type RuneWriter interface {
        // WriteRune writes the UTF-8 encoding of Unicode code point r, 
        // and returns the number of bytes written. In case of an error
        // while writing, the WriteRune method might write part of a
        // UTF-8 representation of that rune.
        // If the rune is out of range, it writes the encoding of [utf8.RuneError].
	WriteRune(r rune) (int, error)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions