File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ impl<T> Receiver<T> {
109109 /// * None when all senders have been dropped and the Receiver is caught up. The Receiver will never receive more messages and you should drop it.
110110 /// * You will never receive an empty iterator.
111111 #[ inline]
112- pub async fn next_batch < ' a > ( & ' a mut self ) -> Option < impl Iterator < Item = T > + ' a > {
112+ pub async fn next_batch < ' a > ( & ' a mut self ) -> Option < impl ExactSizeIterator < Item = T > + ' a > {
113113 std:: future:: poll_fn ( |context| {
114114 match self . poll_next ( context) {
115115 std:: task:: Poll :: Ready ( Some ( next) ) => {
@@ -140,6 +140,17 @@ impl<T> Iterator for BatchDrain<'_, T> {
140140 fn next ( & mut self ) -> Option < Self :: Item > {
141141 self . buffer . pop_front ( )
142142 }
143+
144+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
145+ let len = self . buffer . len ( ) ;
146+ ( len, Some ( len) )
147+ }
148+ }
149+
150+ impl < T > ExactSizeIterator for BatchDrain < ' _ , T > {
151+ fn len ( & self ) -> usize {
152+ self . buffer . len ( )
153+ }
143154}
144155
145156#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments