File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1014,6 +1014,11 @@ impl<A: Step> Iterator for ops::RangeFrom<A> {
10141014
10151015 #[ inline]
10161016 fn next ( & mut self ) -> Option < A > {
1017+ if crate :: intrinsics:: overflow_checks ( ) {
1018+ self . start = Step :: forward ( self . start . clone ( ) , 1 ) ;
1019+ return Some ( self . start . clone ( ) ) ;
1020+ }
1021+
10171022 let n = Step :: forward ( self . start . clone ( ) , 1 ) ;
10181023 Some ( mem:: replace ( & mut self . start , n) )
10191024 }
@@ -1025,6 +1030,12 @@ impl<A: Step> Iterator for ops::RangeFrom<A> {
10251030
10261031 #[ inline]
10271032 fn nth ( & mut self , n : usize ) -> Option < A > {
1033+ if crate :: intrinsics:: overflow_checks ( ) {
1034+ let plus_n = Step :: forward ( self . start . clone ( ) , n) ;
1035+ self . start = Step :: forward ( plus_n. clone ( ) , 1 ) ;
1036+ return Some ( self . start . clone ( ) ) ;
1037+ }
1038+
10281039 let plus_n = Step :: forward ( self . start . clone ( ) , n) ;
10291040 self . start = Step :: forward ( plus_n. clone ( ) , 1 ) ;
10301041 Some ( plus_n)
You can’t perform that action at this time.
0 commit comments