Skip to content

Commit

Permalink
impl Default, Copy, Clone for std::io::Sink and Empty
Browse files Browse the repository at this point in the history
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 Copycan 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.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
  • Loading branch information
ijackson committed Jun 30, 2021
1 parent 7ede6e2 commit a7e88e0
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 a7e88e0

Please sign in to comment.