Closed
Description
Feature gate: #![feature(bufwriter_into_parts)]
This is a tracking issue for BufWriter::into_parts
and its associated error type etc.
This allows a BufWriter
to be disassembled, and the inner writer to be recovered - without attempting to write out any buffered data (instead it is returnedt to the caller), and therefore (unlike into_inner
) succeeding even if the underlying writer is returning errors.
Public API
// std::io
/// Disassembles this `BufWriter<W>`, returning the underlying writer, and any buffered but
/// unwritten data.
impl<W> BufWriter<W> {
pub fn into_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>);
}
/// Error newtype, wraps the buffered data, a `Vec<u8>`
pub struct WriterPanicked {...}
impl WriterPanicked {
pub fn into_inner(self) -> Vec<u8>;
}
impl Error for WriterPanicked {...}
impl Display for WriterPanicked {...}
impl Debug for WriterPanicked {...}
Steps / History
- Implementation: BufWriter: Provide into_raw_parts #79705
- Gain experience with this API, to see if it's good
- Stabilization PR with Final commenting period (FCP)
Unresolved Questions
- Should
into_raw_parts
be calledinto_parts
? Tracking Issue for BufWriter::into_parts #80690 (comment) - Is there a suitable simpler API for presenting this functionality? (I think not, see BufWriter: Provide into_raw_parts #79705 (comment))