File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -826,6 +826,27 @@ impl<V: Ord + Clone> Ranges<V> {
826
826
}
827
827
}
828
828
829
+ // Newtype to avoid leaking our internal representation.
830
+ pub struct RangesIter < V > ( smallvec:: IntoIter < [ Interval < V > ; 1 ] > ) ;
831
+
832
+ impl < V > Iterator for RangesIter < V > {
833
+ type Item = Interval < V > ;
834
+
835
+ fn next ( & mut self ) -> Option < Self :: Item > {
836
+ self . 0 . next ( )
837
+ }
838
+ }
839
+
840
+ impl < V > IntoIterator for Ranges < V > {
841
+ type Item = ( Bound < V > , Bound < V > ) ;
842
+ // Newtype to avoid leaking our internal representation.
843
+ type IntoIter = RangesIter < V > ;
844
+
845
+ fn into_iter ( self ) -> Self :: IntoIter {
846
+ RangesIter ( self . segments . into_iter ( ) )
847
+ }
848
+ }
849
+
829
850
// REPORT ######################################################################
830
851
831
852
impl < V : Display + Eq > Display for Ranges < V > {
You can’t perform that action at this time.
0 commit comments