Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement bufwriter_raw_buffer feature #79921

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions library/std/src/io/buffered/bufwriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ impl<W: Write> BufWriter<W> {
&self.buf
}

/// FIXME Document.
#[inline]
#[unstable(feature = "bufwriter_raw_buffer", issue = "79916")]
pub fn as_ptr(&mut self) -> *const u8 {
self.buf.as_ptr()
}

/// FIXME Document.
#[inline]
#[unstable(feature = "bufwriter_raw_buffer", issue = "79916")]
pub fn as_mut_ptr(&mut self) -> *mut u8 {
self.buf.as_mut_ptr()
}

/// Returns the number of bytes the internal buffer can hold without flushing.
///
/// # Examples
Expand All @@ -261,6 +275,20 @@ impl<W: Write> BufWriter<W> {
self.buf.capacity()
}

/// FIXME Document.
#[inline]
#[unstable(feature = "bufwriter_raw_buffer", issue = "79916")]
pub fn len(&self) -> usize {
self.buf.len()
}

/// FIXME Document.
#[inline]
#[unstable(feature = "bufwriter_raw_buffer", issue = "79916")]
pub unsafe fn set_len(&mut self, new_len: usize) {
self.buf.set_len(new_len);
}

/// Unwraps this `BufWriter<W>`, returning the underlying writer.
///
/// The buffer is written out before returning the writer.
Expand Down