Skip to content

Writer adaptors should have a public method flush_outer() #13858

Closed
@lilyball

Description

@lilyball

All the Writer adaptors that libstd provides that have some sort of internal buffer should expose a method named .flush_outer() that flushes this internal buffer. Basically, whatever it does in .flush() besides flushing the inner writer. For example, in BufferedWriter it would be the flush_buf() method.

This would be useful when the client needs to handle errors from this shallow flush but doesn't want to flush the full writer stack. For example, before calling BufferedWriter.unwrap(), the client could use .flush_buf() to get the error, as BufferedWriter.unwrap() will fail otherwise.

Similarly, LineBufferedWriter could call self.inner.flush_outer() in write() instead of calling self.inner.flush().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions