File tree Expand file tree Collapse file tree 12 files changed +63
-0
lines changed Expand file tree Collapse file tree 12 files changed +63
-0
lines changed Original file line number Diff line number Diff line change @@ -1260,6 +1260,10 @@ impl Iterator for ReadDir {
12601260 fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
12611261 self . 0 . next ( ) . map ( |entry| entry. map ( DirEntry ) )
12621262 }
1263+
1264+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1265+ self . 0 . size_hint ( )
1266+ }
12631267}
12641268
12651269impl DirEntry {
Original file line number Diff line number Diff line change @@ -897,6 +897,10 @@ impl<'a> Iterator for Iter<'a> {
897897 fn next ( & mut self ) -> Option < & ' a OsStr > {
898898 self . inner . next ( ) . map ( Component :: as_os_str)
899899 }
900+
901+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
902+ self . inner . size_hint ( )
903+ }
900904}
901905
902906#[ stable( feature = "rust1" , since = "1.0.0" ) ]
Original file line number Diff line number Diff line change @@ -150,6 +150,10 @@ impl Iterator for ReadDir {
150150 fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
151151 match self . 0 { }
152152 }
153+
154+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
155+ ( 0 , Some ( 0 ) )
156+ }
153157}
154158
155159impl DirEntry {
Original file line number Diff line number Diff line change @@ -289,6 +289,10 @@ impl Iterator for LookupHost {
289289 fn next ( & mut self ) -> Option < SocketAddr > {
290290 match self . 0 { }
291291 }
292+
293+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
294+ ( 0 , Some ( 0 ) )
295+ }
292296}
293297
294298pub fn lookup_host ( _: & str ) -> io:: Result < LookupHost > {
Original file line number Diff line number Diff line change @@ -53,6 +53,10 @@ impl<'a> Iterator for SplitPaths<'a> {
5353 fn next ( & mut self ) -> Option < PathBuf > {
5454 match * self . 0 { }
5555 }
56+
57+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
58+ ( 0 , Some ( 0 ) )
59+ }
5660}
5761
5862#[ derive( Debug ) ]
Original file line number Diff line number Diff line change @@ -167,6 +167,16 @@ impl Iterator for ReadDir {
167167 }
168168 }
169169 }
170+
171+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
172+ // There's at most one entry for every newline; and there are at most
173+ // two skipped entries.
174+ let upper = self . data [ ( i + 1 ) ..] . iter ( )
175+ . filter ( |byte| byte == b'\n' )
176+ . count ( ) ;
177+ let lower = upper. saturating_sub ( 2 ) ;
178+ ( lower, Some ( upper) )
179+ }
170180}
171181
172182impl DirEntry {
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ impl Iterator for LookupHost {
3636 fn next ( & mut self ) -> Option < Self :: Item > {
3737 self . 0 . next ( )
3838 }
39+
40+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
41+ self . 0 . size_hint ( )
42+ }
3943}
4044
4145pub fn lookup_host ( host : & str ) -> Result < LookupHost > {
Original file line number Diff line number Diff line change @@ -429,6 +429,10 @@ pub mod net {
429429 fn next ( & mut self ) -> Option < SocketAddr > {
430430 None
431431 }
432+
433+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
434+ ( 0 , Some ( 0 ) )
435+ }
432436 }
433437
434438 unsafe impl Sync for LookupHost { }
Original file line number Diff line number Diff line change @@ -152,6 +152,10 @@ impl Iterator for ReadDir {
152152 fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
153153 match self . 0 { }
154154 }
155+
156+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
157+ ( 0 , Some ( 0 ) )
158+ }
155159}
156160
157161impl DirEntry {
Original file line number Diff line number Diff line change @@ -291,6 +291,10 @@ impl Iterator for LookupHost {
291291 fn next ( & mut self ) -> Option < SocketAddr > {
292292 match self . 0 { }
293293 }
294+
295+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
296+ ( 0 , Some ( 0 ) )
297+ }
294298}
295299
296300pub fn lookup_host ( _: & str ) -> io:: Result < LookupHost > {
You can’t perform that action at this time.
0 commit comments