Skip to content

Commit

Permalink
bugfix: Manually implement Clone on WeakSender/Receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka authored Jul 5, 2023
1 parent f030a04 commit 49216cd
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,6 @@ impl<T> futures_core::stream::FusedStream for Receiver<T> {
///
/// This is created through the [`Sender::downgrade`] method. In order to use it, it needs
/// to be upgraded into a [`Sender`] through the `upgrade` method.
#[derive(Clone)]
pub struct WeakSender<T> {
channel: Arc<Channel<T>>,
}
Expand Down Expand Up @@ -857,6 +856,14 @@ impl<T> WeakSender<T> {
}
}

impl<T> Clone for WeakSender<T> {
fn clone(&self) -> Self {
WeakSender {
channel: self.channel.clone(),
}
}
}

impl<T> fmt::Debug for WeakSender<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "WeakSender {{ .. }}")
Expand All @@ -867,7 +874,6 @@ impl<T> fmt::Debug for WeakSender<T> {
///
/// This is created through the [`Receiver::downgrade`] method. In order to use it, it needs
/// to be upgraded into a [`Receiver`] through the `upgrade` method.
#[derive(Clone)]
pub struct WeakReceiver<T> {
channel: Arc<Channel<T>>,
}
Expand Down Expand Up @@ -897,6 +903,14 @@ impl<T> WeakReceiver<T> {
}
}

impl<T> Clone for WeakReceiver<T> {
fn clone(&self) -> Self {
WeakReceiver {
channel: self.channel.clone(),
}
}
}

impl<T> fmt::Debug for WeakReceiver<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "WeakReceiver {{ .. }}")
Expand Down

0 comments on commit 49216cd

Please sign in to comment.