Merge rust-bitcoin/rust-bitcoin#1354: Add `impl IntoIterator for &'_ Witness`

d2ed0fe022 Add `impl IntoIterator for &'_ Witness` (Martin Habovstiak)

Pull request description:

  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.

ACKs for top commit:
  apoelstra:
    ACK d2ed0fe022
  tcharding:
    ACK d2ed0fe022

Tree-SHA512: fc891109696de4f349324d6ddc160249ef22510622d9ce72a65b18f085d86b0de0f3ecb4f7060e1eaf716a908029865cd21cda5a6598fc4c16d0540152d9a4c9
This commit is contained in:
Andrew Poelstra 2022-10-28 20:33:47 +00:00
commit d8e94cf181
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
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> 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
#[cfg(feature = "serde")]
impl serde::Serialize for Witness {