@@ -1007,6 +1007,166 @@ fn test_splitator_left_inclusive_reverse_mut() {
10071007 assert_eq ! ( xs. split_left_inclusive_mut( |x| * x == 5 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
10081008}
10091009
1010+ #[ test]
1011+ fn test_rsplitator_inclusive ( ) {
1012+ let xs = & [ 1 , 2 , 3 , 4 , 5 ] ;
1013+
1014+ let splits: & [ & [ _ ] ] = & [ & [ 5 ] , & [ 3 , 4 ] , & [ 1 , 2 ] ] ;
1015+ assert_eq ! ( xs. rsplit_inclusive( |x| * x % 2 == 0 ) . collect:: <Vec <_>>( ) , splits) ;
1016+ let splits: & [ & [ _ ] ] = & [ & [ 2 , 3 , 4 , 5 ] , & [ 1 ] ] ;
1017+ assert_eq ! ( xs. rsplit_inclusive( |x| * x == 1 ) . collect:: <Vec <_>>( ) , splits) ;
1018+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1019+ assert_eq ! ( xs. rsplit_inclusive( |x| * x == 5 ) . collect:: <Vec <_>>( ) , splits) ;
1020+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1021+ assert_eq ! ( xs. rsplit_inclusive( |x| * x == 10 ) . collect:: <Vec <_>>( ) , splits) ;
1022+ let splits: & [ & [ _ ] ] = & [ & [ 5 ] , & [ 4 ] , & [ 3 ] , & [ 2 ] , & [ 1 ] ] ;
1023+ assert_eq ! ( xs. rsplit_inclusive( |_| true ) . collect:: <Vec <_>>( ) , splits) ;
1024+
1025+ let xs: & [ i32 ] = & [ ] ;
1026+ let splits: & [ & [ i32 ] ] = & [ & [ ] ] ;
1027+ assert_eq ! ( xs. rsplit_inclusive( |x| * x == 5 ) . collect:: <Vec <_>>( ) , splits) ;
1028+ }
1029+
1030+ #[ test]
1031+ fn test_rsplitator_inclusive_reverse ( ) {
1032+ let xs = & [ 1 , 2 , 3 , 4 , 5 ] ;
1033+
1034+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 ] , & [ 3 , 4 ] , & [ 5 ] ] ;
1035+ assert_eq ! ( xs. rsplit_inclusive( |x| * x % 2 == 0 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1036+ let splits: & [ & [ _ ] ] = & [ & [ 1 ] , & [ 2 , 3 , 4 , 5 ] ] ;
1037+ assert_eq ! ( xs. rsplit_inclusive( |x| * x == 1 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1038+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1039+ assert_eq ! ( xs. rsplit_inclusive( |x| * x == 5 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1040+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1041+ assert_eq ! ( xs. rsplit_inclusive( |x| * x == 10 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1042+ let splits: & [ & [ _ ] ] = & [ & [ 1 ] , & [ 2 ] , & [ 3 ] , & [ 4 ] , & [ 5 ] ] ;
1043+ assert_eq ! ( xs. rsplit_inclusive( |_| true ) . rev( ) . collect:: <Vec <& [ i32 ] >>( ) , splits) ;
1044+
1045+ let xs: & [ i32 ] = & [ ] ;
1046+ let splits: & [ & [ i32 ] ] = & [ & [ ] ] ;
1047+ assert_eq ! ( xs. rsplit_inclusive( |x| * x == 5 ) . rev( ) . collect:: <Vec <& [ i32 ] >>( ) , splits) ;
1048+ }
1049+
1050+ #[ test]
1051+ fn test_rsplitator_mut_inclusive ( ) {
1052+ let xs = & mut [ 1 , 2 , 3 , 4 , 5 ] ;
1053+
1054+ let splits: & [ & [ _ ] ] = & [ & [ 5 ] , & [ 3 , 4 ] , & [ 1 , 2 ] ] ;
1055+ assert_eq ! ( xs. rsplit_inclusive_mut( |x| * x % 2 == 0 ) . collect:: <Vec <_>>( ) , splits) ;
1056+ let splits: & [ & [ _ ] ] = & [ & [ 2 , 3 , 4 , 5 ] , & [ 1 ] ] ;
1057+ assert_eq ! ( xs. rsplit_inclusive_mut( |x| * x == 1 ) . collect:: <Vec <_>>( ) , splits) ;
1058+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1059+ assert_eq ! ( xs. rsplit_inclusive_mut( |x| * x == 5 ) . collect:: <Vec <_>>( ) , splits) ;
1060+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1061+ assert_eq ! ( xs. rsplit_inclusive_mut( |x| * x == 10 ) . collect:: <Vec <_>>( ) , splits) ;
1062+ let splits: & [ & [ _ ] ] = & [ & [ 5 ] , & [ 4 ] , & [ 3 ] , & [ 2 ] , & [ 1 ] ] ;
1063+ assert_eq ! ( xs. rsplit_inclusive_mut( |_| true ) . collect:: <Vec <_>>( ) , splits) ;
1064+
1065+ let xs: & mut [ i32 ] = & mut [ ] ;
1066+ let splits: & [ & [ i32 ] ] = & [ & [ ] ] ;
1067+ assert_eq ! ( xs. rsplit_inclusive_mut( |x| * x == 5 ) . collect:: <Vec <_>>( ) , splits) ;
1068+ }
1069+
1070+ #[ test]
1071+ fn test_rsplitator_mut_inclusive_reverse ( ) {
1072+ let xs = & mut [ 1 , 2 , 3 , 4 , 5 ] ;
1073+
1074+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 ] , & [ 3 , 4 ] , & [ 5 ] ] ;
1075+ assert_eq ! ( xs. rsplit_inclusive_mut( |x| * x % 2 == 0 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1076+ let splits: & [ & [ _ ] ] = & [ & [ 1 ] , & [ 2 , 3 , 4 , 5 ] ] ;
1077+ assert_eq ! ( xs. rsplit_inclusive_mut( |x| * x == 1 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1078+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1079+ assert_eq ! ( xs. rsplit_inclusive_mut( |x| * x == 5 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1080+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1081+ assert_eq ! ( xs. rsplit_inclusive_mut( |x| * x == 10 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1082+ let splits: & [ & [ _ ] ] = & [ & [ 1 ] , & [ 2 ] , & [ 3 ] , & [ 4 ] , & [ 5 ] ] ;
1083+ assert_eq ! ( xs. rsplit_inclusive_mut( |_| true ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1084+
1085+ let xs: & mut [ i32 ] = & mut [ ] ;
1086+ let splits: & [ & [ i32 ] ] = & [ & [ ] ] ;
1087+ assert_eq ! ( xs. rsplit_inclusive_mut( |x| * x == 5 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1088+ }
1089+
1090+ #[ test]
1091+ fn test_rsplitator_left_inclusive ( ) {
1092+ let xs = & [ 1 , 2 , 3 , 4 , 5 ] ;
1093+
1094+ let splits: & [ & [ _ ] ] = & [ & [ 4 , 5 ] , & [ 2 , 3 ] , & [ 1 ] ] ;
1095+ assert_eq ! ( xs. rsplit_left_inclusive( |x| * x % 2 == 0 ) . collect:: <Vec <_>>( ) , splits) ;
1096+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1097+ assert_eq ! ( xs. rsplit_left_inclusive( |x| * x == 1 ) . collect:: <Vec <_>>( ) , splits) ;
1098+ let splits: & [ & [ _ ] ] = & [ & [ 5 ] , & [ 1 , 2 , 3 , 4 ] ] ;
1099+ assert_eq ! ( xs. rsplit_left_inclusive( |x| * x == 5 ) . collect:: <Vec <_>>( ) , splits) ;
1100+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1101+ assert_eq ! ( xs. rsplit_left_inclusive( |x| * x == 10 ) . collect:: <Vec <_>>( ) , splits) ;
1102+ let splits: & [ & [ _ ] ] = & [ & [ 5 ] , & [ 4 ] , & [ 3 ] , & [ 2 ] , & [ 1 ] ] ;
1103+ assert_eq ! ( xs. rsplit_left_inclusive( |_| true ) . collect:: <Vec <_>>( ) , splits) ;
1104+
1105+ let xs: & [ i32 ] = & [ ] ;
1106+ let splits: & [ & [ i32 ] ] = & [ ] ;
1107+ assert_eq ! ( xs. rsplit_left_inclusive( |x| * x == 5 ) . collect:: <Vec <_>>( ) , splits) ;
1108+ }
1109+
1110+ #[ test]
1111+ fn test_rsplitator_left_inclusive_reverse ( ) {
1112+ let xs = & [ 1 , 2 , 3 , 4 , 5 ] ;
1113+
1114+ let splits: & [ & [ _ ] ] = & [ & [ 1 ] , & [ 2 , 3 ] , & [ 4 , 5 ] ] ;
1115+ assert_eq ! ( xs. rsplit_left_inclusive( |x| * x % 2 == 0 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1116+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1117+ assert_eq ! ( xs. rsplit_left_inclusive( |x| * x == 1 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1118+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 ] , & [ 5 ] ] ;
1119+ assert_eq ! ( xs. rsplit_left_inclusive( |x| * x == 5 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1120+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1121+ assert_eq ! ( xs. rsplit_left_inclusive( |x| * x == 10 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1122+ let splits: & [ & [ _ ] ] = & [ & [ 1 ] , & [ 2 ] , & [ 3 ] , & [ 4 ] , & [ 5 ] ] ;
1123+ assert_eq ! ( xs. rsplit_left_inclusive( |_| true ) . rev( ) . collect:: <Vec <& [ i32 ] >>( ) , splits) ;
1124+
1125+ let xs: & [ i32 ] = & [ ] ;
1126+ let splits: & [ & [ i32 ] ] = & [ ] ;
1127+ assert_eq ! ( xs. rsplit_left_inclusive( |x| * x == 5 ) . rev( ) . collect:: <Vec <& [ i32 ] >>( ) , splits) ;
1128+ }
1129+
1130+ #[ test]
1131+ fn test_rsplitator_left_inclusive_mut ( ) {
1132+ let xs = & mut [ 1 , 2 , 3 , 4 , 5 ] ;
1133+
1134+ let splits: & [ & [ _ ] ] = & [ & [ 4 , 5 ] , & [ 2 , 3 ] , & [ 1 ] ] ;
1135+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |x| * x % 2 == 0 ) . collect:: <Vec <_>>( ) , splits) ;
1136+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1137+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |x| * x == 1 ) . collect:: <Vec <_>>( ) , splits) ;
1138+ let splits: & [ & [ _ ] ] = & [ & [ 5 ] , & [ 1 , 2 , 3 , 4 ] ] ;
1139+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |x| * x == 5 ) . collect:: <Vec <_>>( ) , splits) ;
1140+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1141+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |x| * x == 10 ) . collect:: <Vec <_>>( ) , splits) ;
1142+ let splits: & [ & [ _ ] ] = & [ & [ 5 ] , & [ 4 ] , & [ 3 ] , & [ 2 ] , & [ 1 ] ] ;
1143+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |_| true ) . collect:: <Vec <_>>( ) , splits) ;
1144+
1145+ let xs: & mut [ i32 ] = & mut [ ] ;
1146+ let splits: & [ & [ i32 ] ] = & [ ] ;
1147+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |x| * x == 5 ) . collect:: <Vec <_>>( ) , splits) ;
1148+ }
1149+
1150+ #[ test]
1151+ fn test_rsplitator_left_inclusive_reverse_mut ( ) {
1152+ let xs = & mut [ 1 , 2 , 3 , 4 , 5 ] ;
1153+
1154+ let splits: & [ & [ _ ] ] = & [ & [ 1 ] , & [ 2 , 3 ] , & [ 4 , 5 ] ] ;
1155+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |x| * x % 2 == 0 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1156+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1157+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |x| * x == 1 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1158+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 ] , & [ 5 ] ] ;
1159+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |x| * x == 5 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1160+ let splits: & [ & [ _ ] ] = & [ & [ 1 , 2 , 3 , 4 , 5 ] ] ;
1161+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |x| * x == 10 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1162+ let splits: & [ & [ _ ] ] = & [ & [ 1 ] , & [ 2 ] , & [ 3 ] , & [ 4 ] , & [ 5 ] ] ;
1163+ assert_eq ! ( xs. rsplit_left_inclusive_mut( |_| true ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1164+
1165+ let xs: & mut [ i32 ] = & mut [ ] ;
1166+ let splits: & [ & [ i32 ] ] = & [ ] ;
1167+ assert_eq ! ( xs. split_left_inclusive_mut( |x| * x == 5 ) . rev( ) . collect:: <Vec <_>>( ) , splits) ;
1168+ }
1169+
10101170#[ test]
10111171fn test_splitnator ( ) {
10121172 let xs = & [ 1 , 2 , 3 , 4 , 5 ] ;
0 commit comments