Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions src/blocks/tipset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,21 @@ use thiserror::Error;
/// Equal keys will have equivalent iteration order, but note that the `CIDs`
/// are *not* maintained in the same order as the canonical iteration order of
/// blocks in a tipset (which is by ticket)
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, PartialOrd, Ord, GetSize)]
#[derive(
Clone,
Debug,
PartialEq,
Eq,
Hash,
Serialize,
Deserialize,
PartialOrd,
Ord,
GetSize,
derive_more::IntoIterator,
)]
#[cfg_attr(test, derive(derive_quickcheck_arbitrary::Arbitrary))]
pub struct TipsetKey(SmallCidNonEmptyVec);
pub struct TipsetKey(#[into_iterator(owned, ref)] SmallCidNonEmptyVec);

impl TipsetKey {
// Special encoding to match Lotus.
Expand Down Expand Up @@ -121,26 +133,6 @@ impl fmt::Display for TipsetKey {
}
}

impl<'a> IntoIterator for &'a TipsetKey {
type Item = <&'a SmallCidNonEmptyVec as IntoIterator>::Item;

type IntoIter = <&'a SmallCidNonEmptyVec as IntoIterator>::IntoIter;

fn into_iter(self) -> Self::IntoIter {
(&self.0).into_iter()
}
}

impl IntoIterator for TipsetKey {
type Item = <SmallCidNonEmptyVec as IntoIterator>::Item;

type IntoIter = <SmallCidNonEmptyVec as IntoIterator>::IntoIter;

fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}

#[cfg(test)]
impl Default for TipsetKey {
fn default() -> Self {
Expand Down
28 changes: 0 additions & 28 deletions src/cid_collections/hash_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,31 +73,3 @@ impl FromIterator<Cid> for CidHashSet {
this
}
}

pub struct IntoIter {
inner: hash_map::IntoIter<()>,
}

impl Iterator for IntoIter {
type Item = Cid;

fn next(&mut self) -> Option<Self::Item> {
self.inner.next().map(|(it, ())| it)
}

fn size_hint(&self) -> (usize, Option<usize>) {
self.inner.size_hint()
}
}

impl IntoIterator for CidHashSet {
type Item = Cid;

type IntoIter = IntoIter;

fn into_iter(self) -> Self::IntoIter {
IntoIter {
inner: self.inner.into_iter(),
}
}
}
Loading