Skip to content

Commit 3aaa275

Browse files
committed
BufWriter: rename into_parts from into_raw_parts
I looked in stdlib and as @BurntSushi thought, `raw` is generally used for raw pointers, or other hazardous kinds of thing. stdlib does not have `into_parts` apart from the one I added to `IntoInnerError`. I did an ad-hoc search of the rustdocs for my current game project Otter, which includes quite a large number of dependencies. `into_parts` seems heavily used for things quite like this. So change this name. Suggested-by: Andrew Gallant <[email protected]> Signed-off-by: Ian Jackson <[email protected]>
1 parent 88aecc6 commit 3aaa275

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

library/std/src/io/buffered/bufwriter.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ impl<W: Write> BufWriter<W> {
319319
/// In this case, we return `WriterPanicked` for the buffered data (from which the buffer
320320
/// contents can still be recovered).
321321
///
322-
/// `into_raw_parts` makes no attempt to flush data and cannot fail.
322+
/// `into_parts` makes no attempt to flush data and cannot fail.
323323
///
324324
/// # Examples
325325
///
@@ -331,12 +331,12 @@ impl<W: Write> BufWriter<W> {
331331
/// let mut stream = BufWriter::new(buffer.as_mut());
332332
/// write!(stream, "too much data").unwrap();
333333
/// stream.flush().expect_err("it doesn't fit");
334-
/// let (recovered_writer, buffered_data) = stream.into_raw_parts();
334+
/// let (recovered_writer, buffered_data) = stream.into_parts();
335335
/// assert_eq!(recovered_writer.len(), 0);
336336
/// assert_eq!(&buffered_data.unwrap(), b"ata");
337337
/// ```
338338
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
339-
pub fn into_raw_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>) {
339+
pub fn into_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>) {
340340
let buf = mem::take(&mut self.buf);
341341
let buf = if !self.panicked { Ok(buf) } else { Err(WriterPanicked { buf }) };
342342
(self.inner.take().unwrap(), buf)
@@ -441,7 +441,7 @@ impl<W: Write> BufWriter<W> {
441441
}
442442

443443
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
444-
/// Error returned for the buffered data from `BufWriter::into_raw_parts`, when the underlying
444+
/// Error returned for the buffered data from `BufWriter::into_parts`, when the underlying
445445
/// writer has previously panicked. Contains the (possibly partly written) buffered data.
446446
///
447447
/// # Example
@@ -463,7 +463,7 @@ impl<W: Write> BufWriter<W> {
463463
/// stream.flush().unwrap()
464464
/// }));
465465
/// assert!(result.is_err());
466-
/// let (recovered_writer, buffered_data) = stream.into_raw_parts();
466+
/// let (recovered_writer, buffered_data) = stream.into_parts();
467467
/// assert!(matches!(recovered_writer, PanickingWriter));
468468
/// assert_eq!(buffered_data.unwrap_err().into_inner(), b"some data");
469469
/// ```

0 commit comments

Comments
 (0)