Skip to content

Commit

Permalink
Remove PartialEq/Eq implementations from yamux::WriteQueue (#623)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaka authored May 26, 2023
1 parent e4e6fdb commit c68a40a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
13 changes: 5 additions & 8 deletions lib/src/libp2p/connection/yamux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ enum OutgoingGoAway {
Sent,
}

#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone)]
enum OutgoingSubstreamData {
/// Data is coming from the given substream.
///
Expand Down Expand Up @@ -751,7 +751,7 @@ impl<T> Yamux<T> {
..
},
SubstreamState::Healthy { write_queue, .. },
) if *data == OutgoingSubstreamData::Healthy(substream_id) => {
) if matches!(*data, OutgoingSubstreamData::Healthy(i) if i == substream_id) => {
*data = OutgoingSubstreamData::Obsolete { write_queue };
}
_ => {}
Expand Down Expand Up @@ -1151,10 +1151,7 @@ impl<T> Yamux<T> {
..
},
SubstreamState::Healthy { write_queue, .. },
) if *data
== OutgoingSubstreamData::Healthy(SubstreamId(
*substream_id,
)) =>
) if matches!(*data, OutgoingSubstreamData::Healthy(SubstreamId(i)) if i == *substream_id) =>
{
*data = OutgoingSubstreamData::Obsolete { write_queue };
}
Expand Down Expand Up @@ -1242,8 +1239,8 @@ impl<T> Yamux<T> {
..
},
SubstreamState::Healthy { write_queue, .. },
) if *data
== OutgoingSubstreamData::Healthy(SubstreamId(stream_id)) =>
) if matches!(*data,
OutgoingSubstreamData::Healthy(SubstreamId(i)) if i == stream_id) =>
{
*data = OutgoingSubstreamData::Obsolete { write_queue };
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/libp2p/connection/yamux/write_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ impl AsRef<[u8]> for VecWithOffset {
}
}

// TODO: PartialEq/Eq?!
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone)]
pub struct WriteQueue {
/// Buffer of buffers to be written out.
// TODO: is it a good idea to have an unbounded VecDeque?
Expand Down

0 comments on commit c68a40a

Please sign in to comment.