From 3652f71ade9caa07378ac0225a198e83207f4213 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Wed, 6 Apr 2022 14:26:45 +0100 Subject: [PATCH] sync: add Clone to RecvError types (#4560) --- tokio-stream/src/wrappers/broadcast.rs | 2 +- tokio/src/sync/broadcast.rs | 4 ++-- tokio/src/sync/mpsc/error.rs | 2 +- tokio/src/sync/oneshot.rs | 4 ++-- tokio/src/sync/watch.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tokio-stream/src/wrappers/broadcast.rs b/tokio-stream/src/wrappers/broadcast.rs index 2064973d733..10184bf9410 100644 --- a/tokio-stream/src/wrappers/broadcast.rs +++ b/tokio-stream/src/wrappers/broadcast.rs @@ -18,7 +18,7 @@ pub struct BroadcastStream { } /// An error returned from the inner stream of a [`BroadcastStream`]. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone)] pub enum BroadcastStreamRecvError { /// The receiver lagged too far behind. Attempting to receive again will /// return the oldest message still retained by the channel. diff --git a/tokio/src/sync/broadcast.rs b/tokio/src/sync/broadcast.rs index 3b10cf08ec9..e54fe5c8151 100644 --- a/tokio/src/sync/broadcast.rs +++ b/tokio/src/sync/broadcast.rs @@ -230,7 +230,7 @@ pub mod error { /// /// [`recv`]: crate::sync::broadcast::Receiver::recv /// [`Receiver`]: crate::sync::broadcast::Receiver - #[derive(Debug, PartialEq)] + #[derive(Debug, PartialEq, Clone)] pub enum RecvError { /// There are no more active senders implying no further messages will ever /// be sent. @@ -258,7 +258,7 @@ pub mod error { /// /// [`try_recv`]: crate::sync::broadcast::Receiver::try_recv /// [`Receiver`]: crate::sync::broadcast::Receiver - #[derive(Debug, PartialEq)] + #[derive(Debug, PartialEq, Clone)] pub enum TryRecvError { /// The channel is currently empty. There are still active /// [`Sender`] handles, so data may yet become available. diff --git a/tokio/src/sync/mpsc/error.rs b/tokio/src/sync/mpsc/error.rs index 3fe6bac5e17..1c789da0cdd 100644 --- a/tokio/src/sync/mpsc/error.rs +++ b/tokio/src/sync/mpsc/error.rs @@ -78,7 +78,7 @@ impl Error for TryRecvError {} // ===== RecvError ===== /// Error returned by `Receiver`. -#[derive(Debug)] +#[derive(Debug, Clone)] #[doc(hidden)] #[deprecated(note = "This type is unused because recv returns an Option.")] pub struct RecvError(()); diff --git a/tokio/src/sync/oneshot.rs b/tokio/src/sync/oneshot.rs index 275f8d84e5f..d5fc811da2a 100644 --- a/tokio/src/sync/oneshot.rs +++ b/tokio/src/sync/oneshot.rs @@ -323,11 +323,11 @@ pub mod error { use std::fmt; /// Error returned by the `Future` implementation for `Receiver`. - #[derive(Debug, Eq, PartialEq)] + #[derive(Debug, Eq, PartialEq, Clone)] pub struct RecvError(pub(super) ()); /// Error returned by the `try_recv` function on `Receiver`. - #[derive(Debug, Eq, PartialEq)] + #[derive(Debug, Eq, PartialEq, Clone)] pub enum TryRecvError { /// The send half of the channel has not yet sent a value. Empty, diff --git a/tokio/src/sync/watch.rs b/tokio/src/sync/watch.rs index 42be67613e7..afeb7c2c9f7 100644 --- a/tokio/src/sync/watch.rs +++ b/tokio/src/sync/watch.rs @@ -155,7 +155,7 @@ pub mod error { impl std::error::Error for SendError {} /// Error produced when receiving a change notification. - #[derive(Debug)] + #[derive(Debug, Clone)] pub struct RecvError(pub(super) ()); // ===== impl RecvError =====