Use d-a for our ad-hoc BinaryHeap entry implementations
We have a lot of types meant for use in a std BinaryHeap to make it behave as a min-heap instead of max-heap. These types all have formulaic Ord
/ParialOrd
/Eq
/PartialEq
impls
impl Ord for ReuploadTimer {
fn cmp(&self, other: &Self) -> Ordering {
// Reversed, because we want the earlier
// `ReuploadTimer` to be "greater".
self.when.cmp(&other.when).reverse()
}
}
impl PartialOrd for ReuploadTimer {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl PartialEq for ReuploadTimer {
fn eq(&self, other: &Self) -> bool {
self.when == other.when
}
}
impl Eq for ReuploadTimer {}
impl<TT: Ord, RD> Ord for RefetchEntry<TT, RD> {
fn cmp(&self, other: &Self) -> Ordering {
self.when.cmp(&other.when).reverse()
// We don't care about the ordering of BridgeConfig or retry_delay.
// Different BridgeConfig with the same fetch time will be fetched in "some order".
}
}
impl<TT: Ord, RD> PartialOrd for RefetchEntry<TT, RD> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<TT: Ord, RD> PartialEq for RefetchEntry<TT, RD> {
fn eq(&self, other: &Self) -> bool {
self.cmp(other) == Ordering::Equal
}
}
impl<TT: Ord, RD> Eq for RefetchEntry<TT, RD> {}
impl PartialEq for SleepEntry {
fn eq(&self, other: &Self) -> bool {
self.when == other.when
}
}
impl Eq for SleepEntry {}
impl PartialOrd for SleepEntry {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for SleepEntry {
fn cmp(&self, other: &Self) -> Ordering {
self.when.cmp(&other.when).reverse()
}
}
impl<TT: Ord, RD> Ord for RefetchEntry<TT, RD> {
fn cmp(&self, other: &Self) -> Ordering {
self.when.cmp(&other.when).reverse()
// We don't care about the ordering of BridgeConfig or retry_delay.
// Different BridgeConfig with the same fetch time will be fetched in "some order".
}
}
impl<TT: Ord, RD> PartialOrd for RefetchEntry<TT, RD> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl<TT: Ord, RD> PartialEq for RefetchEntry<TT, RD> {
fn eq(&self, other: &Self) -> bool {
self.cmp(other) == Ordering::Equal
}
}
impl<TT: Ord, RD> Eq for RefetchEntry<TT, RD> {}
And I'm about to add another such type!
ISTM these could all be auto-generated (probably with d-a).