diff --git a/src/primitives/decode.rs b/src/primitives/decode.rs index 89a7edb93..f7a8be260 100644 --- a/src/primitives/decode.rs +++ b/src/primitives/decode.rs @@ -373,6 +373,16 @@ impl<'s> CheckedHrpstring<'s> { #[inline] pub fn data_part_ascii_no_checksum(&self) -> &[u8] { self.ascii } + /// Returns an iterator that yields the data part of the parsed bech32 encoded string as [`Fe32`]s. + /// + /// Converts the ASCII bytes representing field elements to the respective field elements. + #[inline] + pub fn fe32_iter>( + &self, + ) -> AsciiToFe32Iter>> { + AsciiToFe32Iter { iter: self.ascii.iter().copied() } + } + /// Returns an iterator that yields the data part of the parsed bech32 encoded string. /// /// Converts the ASCII bytes representing field elements to the respective field elements, then @@ -658,14 +668,14 @@ impl<'s> Iterator for Fe32Iter<'s> { fn size_hint(&self) -> (usize, Option) { self.iter.size_hint() } } -/// Helper iterator adaptor that maps an iterator of valid bech32 character ASCII bytes to an +/// Iterator adaptor that maps an iterator of valid bech32 character ASCII bytes to an /// iterator of field elements. /// /// # Panics /// /// If any `u8` in the input iterator is out of range for an [`Fe32`]. Should only be used on data /// that has already been checked for validity (eg, by using `check_characters`). -struct AsciiToFe32Iter> { +pub struct AsciiToFe32Iter> { iter: I, }