File tree 12 files changed +63
-0
lines changed 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 {
1260
1260
fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
1261
1261
self . 0 . next ( ) . map ( |entry| entry. map ( DirEntry ) )
1262
1262
}
1263
+
1264
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
1265
+ self . 0 . size_hint ( )
1266
+ }
1263
1267
}
1264
1268
1265
1269
impl DirEntry {
Original file line number Diff line number Diff line change @@ -897,6 +897,10 @@ impl<'a> Iterator for Iter<'a> {
897
897
fn next ( & mut self ) -> Option < & ' a OsStr > {
898
898
self . inner . next ( ) . map ( Component :: as_os_str)
899
899
}
900
+
901
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
902
+ self . inner . size_hint ( )
903
+ }
900
904
}
901
905
902
906
#[ 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 {
150
150
fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
151
151
match self . 0 { }
152
152
}
153
+
154
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
155
+ ( 0 , Some ( 0 ) )
156
+ }
153
157
}
154
158
155
159
impl DirEntry {
Original file line number Diff line number Diff line change @@ -289,6 +289,10 @@ impl Iterator for LookupHost {
289
289
fn next ( & mut self ) -> Option < SocketAddr > {
290
290
match self . 0 { }
291
291
}
292
+
293
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
294
+ ( 0 , Some ( 0 ) )
295
+ }
292
296
}
293
297
294
298
pub 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> {
53
53
fn next ( & mut self ) -> Option < PathBuf > {
54
54
match * self . 0 { }
55
55
}
56
+
57
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
58
+ ( 0 , Some ( 0 ) )
59
+ }
56
60
}
57
61
58
62
#[ derive( Debug ) ]
Original file line number Diff line number Diff line change @@ -167,6 +167,16 @@ impl Iterator for ReadDir {
167
167
}
168
168
}
169
169
}
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
+ }
170
180
}
171
181
172
182
impl DirEntry {
Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ impl Iterator for LookupHost {
36
36
fn next ( & mut self ) -> Option < Self :: Item > {
37
37
self . 0 . next ( )
38
38
}
39
+
40
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
41
+ self . 0 . size_hint ( )
42
+ }
39
43
}
40
44
41
45
pub fn lookup_host ( host : & str ) -> Result < LookupHost > {
Original file line number Diff line number Diff line change @@ -429,6 +429,10 @@ pub mod net {
429
429
fn next ( & mut self ) -> Option < SocketAddr > {
430
430
None
431
431
}
432
+
433
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
434
+ ( 0 , Some ( 0 ) )
435
+ }
432
436
}
433
437
434
438
unsafe impl Sync for LookupHost { }
Original file line number Diff line number Diff line change @@ -152,6 +152,10 @@ impl Iterator for ReadDir {
152
152
fn next ( & mut self ) -> Option < io:: Result < DirEntry > > {
153
153
match self . 0 { }
154
154
}
155
+
156
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
157
+ ( 0 , Some ( 0 ) )
158
+ }
155
159
}
156
160
157
161
impl DirEntry {
Original file line number Diff line number Diff line change @@ -291,6 +291,10 @@ impl Iterator for LookupHost {
291
291
fn next ( & mut self ) -> Option < SocketAddr > {
292
292
match self . 0 { }
293
293
}
294
+
295
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
296
+ ( 0 , Some ( 0 ) )
297
+ }
294
298
}
295
299
296
300
pub fn lookup_host ( _: & str ) -> io:: Result < LookupHost > {
Original file line number Diff line number Diff line change @@ -43,6 +43,10 @@ impl<'a> Iterator for SplitPaths<'a> {
43
43
fn next ( & mut self ) -> Option < PathBuf > {
44
44
match * self . 0 { }
45
45
}
46
+
47
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
48
+ ( 0 , Some ( 0 ) )
49
+ }
46
50
}
47
51
48
52
#[ derive( Debug ) ]
@@ -77,6 +81,10 @@ impl Iterator for Env {
77
81
fn next ( & mut self ) -> Option < ( OsString , OsString ) > {
78
82
match self . 0 { }
79
83
}
84
+
85
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
86
+ ( 0 , Some ( 0 ) )
87
+ }
80
88
}
81
89
82
90
pub fn env ( ) -> Env {
Original file line number Diff line number Diff line change @@ -192,6 +192,15 @@ impl<'a> Iterator for SplitPaths<'a> {
192
192
Some ( super :: os2path ( & in_progress) )
193
193
}
194
194
}
195
+
196
+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
197
+ // There will be at most N + 1 entries, where N is the number of
198
+ // remaining semicolons.
199
+ let data = self . data . clone ( ) ;
200
+ let semicolons = data. filter ( |b| b == ( ';' as u16 ) ) . count ( ) ;
201
+
202
+ ( 0 , Some ( semicolons + 1 ) )
203
+ }
195
204
}
196
205
197
206
#[ derive( Debug ) ]
You can’t perform that action at this time.
0 commit comments