From d2ed0fe022a582896b8221f0ac4911ae4869cec0 Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Fri, 28 Oct 2022 13:07:08 +0200 Subject: [PATCH] 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. --- bitcoin/src/blockdata/witness.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bitcoin/src/blockdata/witness.rs b/bitcoin/src/blockdata/witness.rs index 179fa541..40311121 100644 --- a/bitcoin/src/blockdata/witness.rs +++ b/bitcoin/src/blockdata/witness.rs @@ -274,6 +274,15 @@ impl<'a> Iterator 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> format #[cfg(feature = "serde")] impl serde::Serialize for Witness {