@@ -77,8 +77,18 @@ impl<'a, 'tcx> Iterator for Preorder<'a, 'tcx> {
7777
7878 None
7979 }
80+
81+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
82+ // All the blocks, minus the number of blocks we've visited.
83+ let remaining = self . mir . basic_blocks ( ) . len ( ) - self . visited . count ( ) ;
84+
85+ // We will visit all remaining blocks exactly once.
86+ ( remaining, Some ( remaining) )
87+ }
8088}
8189
90+ impl < ' a , ' tcx > ExactSizeIterator for Preorder < ' a , ' tcx > { }
91+
8292/// Postorder traversal of a graph.
8393///
8494/// Postorder traversal is when each node is visited after all of it's
@@ -210,8 +220,18 @@ impl<'a, 'tcx> Iterator for Postorder<'a, 'tcx> {
210220
211221 next. map ( |( bb, _) | ( bb, & self . mir [ bb] ) )
212222 }
223+
224+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
225+ // All the blocks, minus the number of blocks we've visited.
226+ let remaining = self . mir . basic_blocks ( ) . len ( ) - self . visited . count ( ) ;
227+
228+ // We will visit all remaining blocks exactly once.
229+ ( remaining, Some ( remaining) )
230+ }
213231}
214232
233+ impl < ' a , ' tcx > ExactSizeIterator for Postorder < ' a , ' tcx > { }
234+
215235/// Reverse postorder traversal of a graph
216236///
217237/// Reverse postorder is the reverse order of a postorder traversal.
@@ -276,4 +296,10 @@ impl<'a, 'tcx> Iterator for ReversePostorder<'a, 'tcx> {
276296
277297 self . blocks . get ( self . idx ) . map ( |& bb| ( bb, & self . mir [ bb] ) )
278298 }
299+
300+ fn size_hint ( & self ) -> ( usize , Option < usize > ) {
301+ ( self . idx , Some ( self . idx ) )
302+ }
279303}
304+
305+ impl < ' a , ' tcx > ExactSizeIterator for ReversePostorder < ' a , ' tcx > { }
0 commit comments