diff --git a/src/chunk.rs b/src/chunk.rs index 92706030..9d2c6125 100644 --- a/src/chunk.rs +++ b/src/chunk.rs @@ -20,6 +20,12 @@ pub struct Chunk { _flow_control: Option, } +// An unexported type to prevent locking `Chunk::into_iter()` to `Bytes::into_iter()`. +#[derive(Debug)] +pub struct IntoIter { + inner: ::IntoIter, +} + struct AutoRelease { cap: usize, release: ReleaseCapacity, @@ -147,11 +153,13 @@ impl Default for Chunk { impl IntoIterator for Chunk { type Item = u8; - type IntoIter = ::IntoIter; + type IntoIter = IntoIter; #[inline] fn into_iter(self) -> Self::IntoIter { - self.bytes.into_iter() + IntoIter { + inner: self.bytes.into_iter(), + } } } @@ -161,3 +169,13 @@ impl Extend for Chunk { self.bytes.extend(iter) } } + +impl Iterator for IntoIter { + type Item = u8; + + #[inline] + fn next(&mut self) -> Option { + self.inner.next() + } +} +