Skip to content

Commit 66f3807

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 cbba940 commit 66f3807

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ impl<W: Write> BufWriter<W> {
307307
pub fn into_inner(mut self) -> Result<W, IntoInnerError<BufWriter<W>>> {
308308
match self.flush_buf() {
309309
Err(e) => Err(IntoInnerError::new(self, e)),
310-
Ok(()) => Ok(self.into_raw_parts().0),
310+
Ok(()) => Ok(self.into_parts().0),
311311
}
312312
}
313313

@@ -318,7 +318,7 @@ impl<W: Write> BufWriter<W> {
318318
/// In this case, we return `WriterPanicked` for the buffered data (from which the buffer
319319
/// contents can still be recovered).
320320
///
321-
/// `into_raw_parts` makes no attempt to flush data and cannot fail.
321+
/// `into_parts` makes no attempt to flush data and cannot fail.
322322
///
323323
/// # Examples
324324
///
@@ -330,12 +330,12 @@ impl<W: Write> BufWriter<W> {
330330
/// let mut stream = BufWriter::new(buffer.as_mut());
331331
/// write!(stream, "too much data").unwrap();
332332
/// stream.flush().expect_err("it doesn't fit");
333-
/// let (recovered_writer, buffered_data) = stream.into_raw_parts();
333+
/// let (recovered_writer, buffered_data) = stream.into_parts();
334334
/// assert_eq!(recovered_writer.len(), 0);
335335
/// assert_eq!(&buffered_data.unwrap(), b"ata");
336336
/// ```
337337
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
338-
pub fn into_raw_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>) {
338+
pub fn into_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>) {
339339
let buf = mem::take(&mut self.buf);
340340
let buf = if !self.panicked { Ok(buf) } else { Err(WriterPanicked { buf }) };
341341

@@ -445,7 +445,7 @@ impl<W: Write> BufWriter<W> {
445445
}
446446

447447
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
448-
/// Error returned for the buffered data from `BufWriter::into_raw_parts`, when the underlying
448+
/// Error returned for the buffered data from `BufWriter::into_parts`, when the underlying
449449
/// writer has previously panicked. Contains the (possibly partly written) buffered data.
450450
///
451451
/// # Example
@@ -467,7 +467,7 @@ impl<W: Write> BufWriter<W> {
467467
/// stream.flush().unwrap()
468468
/// }));
469469
/// assert!(result.is_err());
470-
/// let (recovered_writer, buffered_data) = stream.into_raw_parts();
470+
/// let (recovered_writer, buffered_data) = stream.into_parts();
471471
/// assert!(matches!(recovered_writer, PanickingWriter));
472472
/// assert_eq!(buffered_data.unwrap_err().into_inner(), b"some data");
473473
/// ```

0 commit comments

Comments
 (0)