Add `impl IntoIterator for &'_ Witness`

It is considered idiomatic for types that have `iter()` method to also
implement `IntoIterator` for their references. `Witness` was missing
this so it is added here.
This commit is contained in:
Martin Habovstiak 2022-10-28 13:07:08 +02:00
parent 21ae79bed4
commit d2ed0fe022
1 changed files with 9 additions and 0 deletions

View File

@ -274,6 +274,15 @@ impl<'a> Iterator for Iter<'a> {
impl<'a> ExactSizeIterator for Iter<'a> {} impl<'a> ExactSizeIterator for Iter<'a> {}
impl<'a> IntoIterator for &'a Witness {
type IntoIter = Iter<'a>;
type Item = &'a [u8];
fn into_iter(self) -> Self::IntoIter {
self.iter()
}
}
// Serde keep backward compatibility with old Vec<Vec<u8>> format // Serde keep backward compatibility with old Vec<Vec<u8>> format
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
impl serde::Serialize for Witness { impl serde::Serialize for Witness {