refactor(chunk): hide Chunk::into_iter type
This commit is contained in:
		
							
								
								
									
										22
									
								
								src/chunk.rs
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/chunk.rs
									
									
									
									
									
								
							| @@ -20,6 +20,12 @@ pub struct Chunk { | |||||||
|     _flow_control: Option<AutoRelease>, |     _flow_control: Option<AutoRelease>, | ||||||
| } | } | ||||||
|  |  | ||||||
|  | // An unexported type to prevent locking `Chunk::into_iter()` to `Bytes::into_iter()`. | ||||||
|  | #[derive(Debug)] | ||||||
|  | pub struct IntoIter { | ||||||
|  |     inner: <Bytes as IntoIterator>::IntoIter, | ||||||
|  | } | ||||||
|  |  | ||||||
| struct AutoRelease { | struct AutoRelease { | ||||||
|     cap: usize, |     cap: usize, | ||||||
|     release: ReleaseCapacity, |     release: ReleaseCapacity, | ||||||
| @@ -147,11 +153,13 @@ impl Default for Chunk { | |||||||
|  |  | ||||||
| impl IntoIterator for Chunk { | impl IntoIterator for Chunk { | ||||||
|     type Item = u8; |     type Item = u8; | ||||||
|     type IntoIter = <Bytes as IntoIterator>::IntoIter; |     type IntoIter = IntoIter; | ||||||
|  |  | ||||||
|     #[inline] |     #[inline] | ||||||
|     fn into_iter(self) -> Self::IntoIter { |     fn into_iter(self) -> Self::IntoIter { | ||||||
|         self.bytes.into_iter() |         IntoIter { | ||||||
|  |             inner: self.bytes.into_iter(), | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -161,3 +169,13 @@ impl Extend<u8> for Chunk { | |||||||
|         self.bytes.extend(iter) |         self.bytes.extend(iter) | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | impl Iterator for IntoIter { | ||||||
|  |     type Item = u8; | ||||||
|  |  | ||||||
|  |     #[inline] | ||||||
|  |     fn next(&mut self) -> Option<Self::Item> { | ||||||
|  |         self.inner.next() | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user