Skip to content

Commit 8622a8f

Browse files
committed
bit_machine: return concrete type from as_bit_iter
Returning a concrete type lets us get more trait methods rather than just `Iterator`. In particular we should be able to get `ExactSizeIterator` and `Fuse` which are important for efficiency. We also want to name this type elsewhere, and even the existential one was annoying to type, so we add an alias for it.
1 parent 7ecf394 commit 8622a8f

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/bit_machine/frame.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl Frame {
104104

105105
/// Extend the present frame with a read-only reference the the data
106106
/// and return the resulting struct.
107-
pub fn as_bit_iter<'a>(&self, data: &'a [u8]) -> BitIter<impl Iterator<Item = u8> + 'a> {
107+
pub(super) fn as_bit_iter<'a>(&self, data: &'a [u8]) -> super::FrameIter<'a> {
108108
BitIter::byte_slice_window(data, self.start, self.start + self.len)
109109
}
110110
}

src/bit_machine/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ use simplicity_sys::ffi::UWORD;
2424

2525
pub use self::limits::LimitError;
2626

27+
/// An iterator over the contents of a read or write frame which yields bits.
28+
pub type FrameIter<'a> = crate::BitIter<core::iter::Copied<core::slice::Iter<'a, u8>>>;
29+
2730
/// An execution context for a Simplicity program
2831
pub struct BitMachine {
2932
/// Space for bytes that read and write frames point to.

0 commit comments

Comments
 (0)