fix(traverse): use Conway types in places they are meant to (#499)

This commit is contained in:
Matthias Benkort 2024-08-08 13:33:10 +02:00 committed by GitHub
parent 2758cc5a2c
commit afc93b2c3c
8 changed files with 78 additions and 22 deletions

View file

@ -175,6 +175,22 @@ where
Indef(Vec<(K, V)>),
}
impl<K, V> IntoIterator for NonEmptyKeyValuePairs<K, V>
where
K: Clone,
V: Clone,
{
type Item = (K, V);
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
match self {
NonEmptyKeyValuePairs::Def(pairs) => pairs.into_iter(),
NonEmptyKeyValuePairs::Indef(pairs) => pairs.into_iter(),
}
}
}
impl<K, V> NonEmptyKeyValuePairs<K, V>
where
K: Clone,
@ -911,6 +927,12 @@ impl From<PositiveCoin> for u64 {
}
}
impl From<&PositiveCoin> for u64 {
fn from(x: &PositiveCoin) -> Self {
u64::from(*x)
}
}
impl<'b, C> minicbor::decode::Decode<'b, C> for PositiveCoin {
fn decode(d: &mut minicbor::Decoder<'b>, ctx: &mut C) -> Result<Self, minicbor::decode::Error> {
let n = d.decode_with(ctx)?;