Skip to content

Commit

Permalink
use derive(Debug) instead of derive_where(Debug)
Browse files Browse the repository at this point in the history
  • Loading branch information
stojanovic00 committed Feb 4, 2025
1 parent 44b82a7 commit 2dc9e42
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions code/crates/starknet/host/src/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,39 @@ use std::fmt::Debug;
// The default BinaryHeap is a max-heap, so we reverse the ordering
// by implementing Ord in reverse to make it min-heap, which suits the purpose of efficiently
// providing available proposal part with smallest sequence number
#[derive_where(Debug)]
pub struct MinSeq<T: Debug>(pub StreamMessage<T>);
#[derive(Debug)]
pub struct MinSeq<T>(pub StreamMessage<T>);

impl<T: Debug> PartialEq for MinSeq<T> {
impl<T> PartialEq for MinSeq<T> {
fn eq(&self, other: &Self) -> bool {
self.0.sequence == other.0.sequence
}
}

impl<T: Debug> Eq for MinSeq<T> {}
impl<T> Eq for MinSeq<T> {}

impl<T: Debug> Ord for MinSeq<T> {
impl<T> Ord for MinSeq<T> {
fn cmp(&self, other: &Self) -> Ordering {
other.0.sequence.cmp(&self.0.sequence)
}
}

impl<T: Debug> PartialOrd for MinSeq<T> {
impl<T> PartialOrd for MinSeq<T> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}

#[derive_where(Debug)]
pub struct MinHeap<T: Debug>(pub BinaryHeap<MinSeq<T>>);
#[derive(Debug)]
pub struct MinHeap<T>(pub BinaryHeap<MinSeq<T>>);

impl<T: Debug> Default for MinHeap<T> {
impl<T> Default for MinHeap<T> {
fn default() -> Self {
Self(BinaryHeap::new())
}
}

impl<T: Debug> MinHeap<T> {
impl<T> MinHeap<T> {
fn push(&mut self, msg: StreamMessage<T>) {
self.0.push(MinSeq(msg));
}
Expand All @@ -61,8 +61,9 @@ impl<T: Debug> MinHeap<T> {
self.0.peek().map(|msg| &msg.0)
}
}
#[derive_where(Default, Debug)]
pub struct StreamState<T: Debug> {
#[derive(Debug)]
#[derive_where(Default)]
pub struct StreamState<T> {
pub buffer: MinHeap<T>,
pub init_info: Option<ProposalInit>,
pub seen_sequences: HashSet<Sequence>,
Expand All @@ -72,7 +73,7 @@ pub struct StreamState<T: Debug> {
pub emitted_messages: usize,
}

impl<T: Debug> StreamState<T> {
impl<T> StreamState<T> {
fn has_emitted_all_messages(&self) -> bool {
self.fin_received && self.emitted_messages == self.total_messages
}
Expand Down

0 comments on commit 2dc9e42

Please sign in to comment.