Skip to content

Commit

Permalink
Auto merge of #86744 - ijackson:sink-default, r=dtolnay
Browse files Browse the repository at this point in the history
impl Default, Copy, Clone for std::io::Sink and Empty

The omission of `Sink: Default` is causing me a slight inconvenience in a test harness.  There seems little reason for this and `Empty` not to be `Clone` and `Copy` too.

I have made all three of these insta-stable, because:

AIUI `Copy` can only be derived, and I was not able to find any examples of how to unstably derive it.  I think it is probably not possible.

I hunted through the git history for precedent and found

> 79b8ad8
> Implement `Copy` for `IoSlice`
> #69403

which was also insta-stable.
  • Loading branch information
bors committed Aug 8, 2021
2 parents 798446f + a7e88e0 commit 835dce5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/std/src/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::io::{
/// the documentation of [`empty()`] for more details.
#[stable(feature = "rust1", since = "1.0.0")]
#[non_exhaustive]
#[derive(Copy, Clone, Default)]
pub struct Empty;

/// Constructs a new handle to an empty reader.
Expand Down Expand Up @@ -172,6 +173,7 @@ impl fmt::Debug for Repeat {
/// see the documentation of [`sink()`] for more details.
#[stable(feature = "rust1", since = "1.0.0")]
#[non_exhaustive]
#[derive(Copy, Clone, Default)]
pub struct Sink;

/// Creates an instance of a writer which will successfully consume all data.
Expand Down

0 comments on commit 835dce5

Please sign in to comment.