File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,16 @@ impl<A: Step> Iterator for ops::Range<A> {
252252 None
253253 }
254254
255+ #[ inline]
256+ fn last ( mut self ) -> Option < A > {
257+ self . next_back ( )
258+ }
259+
260+ #[ inline]
261+ fn min ( mut self ) -> Option < A > {
262+ self . next ( )
263+ }
264+
255265 #[ inline]
256266 fn max ( mut self ) -> Option < A > {
257267 self . next_back ( )
Original file line number Diff line number Diff line change @@ -1353,10 +1353,14 @@ fn test_range_step() {
13531353}
13541354
13551355#[ test]
1356- fn test_range_max ( ) {
1357- assert_eq ! ( ( 0 ..100 ) . max( ) , Some ( 99 ) ) ;
1358- assert_eq ! ( ( -20 ..-10 ) . max( ) , Some ( -11 ) ) ;
1359- assert_eq ! ( ( 1 ..1 ) . max( ) , None ) ;
1356+ fn test_range_last_max ( ) {
1357+ assert_eq ! ( ( 0 ..20 ) . last( ) , Some ( 19 ) ) ;
1358+ assert_eq ! ( ( -20 ..0 ) . last( ) , Some ( -1 ) ) ;
1359+ assert_eq ! ( ( 5 ..5 ) . last( ) , None ) ;
1360+
1361+ assert_eq ! ( ( 0 ..20 ) . max( ) , Some ( 19 ) ) ;
1362+ assert_eq ! ( ( -20 ..0 ) . max( ) , Some ( -1 ) ) ;
1363+ assert_eq ! ( ( 5 ..5 ) . max( ) , None ) ;
13601364}
13611365
13621366#[ test]
@@ -1376,6 +1380,13 @@ fn test_range_inclusive_last_max() {
13761380 assert_eq ! ( r. max( ) , None ) ;
13771381}
13781382
1383+ #[ test]
1384+ fn test_range_min ( ) {
1385+ assert_eq ! ( ( 0 ..20 ) . min( ) , Some ( 0 ) ) ;
1386+ assert_eq ! ( ( -20 ..0 ) . min( ) , Some ( -20 ) ) ;
1387+ assert_eq ! ( ( 5 ..5 ) . min( ) , None ) ;
1388+ }
1389+
13791390#[ test]
13801391fn test_range_inclusive_min ( ) {
13811392 assert_eq ! ( ( 0 ..=20 ) . min( ) , Some ( 0 ) ) ;
You can’t perform that action at this time.
0 commit comments