Skip to content

Commit af62d11

Browse files
authored
Rollup merge of rust-lang#85901 - ijackson:bufwriter-tweaks, r=joshtriplett
Bufwriter disassembly tweaks In rust-lang#80690 `@BurntSushi` observed that `WriterPanicked` was erroneously not exported, and suggested renaming `into_raw_parts` to `into_parts`. (More info in my commit messages.) r? `@BurntSushi`
2 parents efa3a2f + 51d16ac commit af62d11

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

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

+13-13
Original file line numberDiff line numberDiff line change
@@ -318,24 +318,24 @@ 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
///
325325
/// ```
326-
/// #![feature(bufwriter_into_raw_parts)]
326+
/// #![feature(bufwriter_into_parts)]
327327
/// use std::io::{BufWriter, Write};
328328
///
329329
/// let mut buffer = [0u8; 10];
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
/// ```
337-
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
338-
pub fn into_raw_parts(mut self) -> (W, Result<Vec<u8>, WriterPanicked>) {
337+
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
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

@@ -444,14 +444,14 @@ impl<W: Write> BufWriter<W> {
444444
}
445445
}
446446

447-
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
448-
/// Error returned for the buffered data from `BufWriter::into_raw_parts`, when the underlying
447+
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
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
452452
///
453453
/// ```
454-
/// #![feature(bufwriter_into_raw_parts)]
454+
/// #![feature(bufwriter_into_parts)]
455455
/// use std::io::{self, BufWriter, Write};
456456
/// use std::panic::{catch_unwind, AssertUnwindSafe};
457457
///
@@ -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
/// ```
@@ -478,7 +478,7 @@ pub struct WriterPanicked {
478478
impl WriterPanicked {
479479
/// Returns the perhaps-unwritten data. Some of this data may have been written by the
480480
/// panicking call(s) to the underlying writer, so simply writing it again is not a good idea.
481-
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
481+
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
482482
pub fn into_inner(self) -> Vec<u8> {
483483
self.buf
484484
}
@@ -487,22 +487,22 @@ impl WriterPanicked {
487487
"BufWriter inner writer panicked, what data remains unwritten is not known";
488488
}
489489

490-
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
490+
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
491491
impl error::Error for WriterPanicked {
492492
#[allow(deprecated, deprecated_in_future)]
493493
fn description(&self) -> &str {
494494
Self::DESCRIPTION
495495
}
496496
}
497497

498-
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
498+
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
499499
impl fmt::Display for WriterPanicked {
500500
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
501501
write!(f, "{}", Self::DESCRIPTION)
502502
}
503503
}
504504

505-
#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")]
505+
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
506506
impl fmt::Debug for WriterPanicked {
507507
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
508508
f.debug_struct("WriterPanicked")

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

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use crate::io::Error;
1414

1515
pub use bufreader::BufReader;
1616
pub use bufwriter::BufWriter;
17+
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
18+
pub use bufwriter::WriterPanicked;
1719
pub use linewriter::LineWriter;
1820
use linewritershim::LineWriterShim;
1921

library/std/src/io/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ use crate::sys_common::memchr;
264264

265265
#[stable(feature = "rust1", since = "1.0.0")]
266266
pub use self::buffered::IntoInnerError;
267+
#[unstable(feature = "bufwriter_into_parts", issue = "80690")]
268+
pub use self::buffered::WriterPanicked;
267269
#[stable(feature = "rust1", since = "1.0.0")]
268270
pub use self::buffered::{BufReader, BufWriter, LineWriter};
269271
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)