@@ -4,17 +4,17 @@ use core::iter::{self, Iterator};
4
4
use super :: * ;
5
5
6
6
#[ test]
7
- fn test_iterator_array_chunks_infer ( ) {
7
+ fn test_iterator_chunks_infer ( ) {
8
8
let xs = [ 1 , 1 , 2 , -2 , 6 , 0 , 3 , 1 ] ;
9
- for [ a, b, c] in xs. iter ( ) . copied ( ) . array_chunks ( ) {
9
+ for [ a, b, c] in xs. iter ( ) . copied ( ) . chunks ( ) {
10
10
assert_eq ! ( a + b + c, 4 ) ;
11
11
}
12
12
}
13
13
14
14
#[ test]
15
- fn test_iterator_array_chunks_clone_and_drop ( ) {
15
+ fn test_iterator_chunks_clone_and_drop ( ) {
16
16
let count = Cell :: new ( 0 ) ;
17
- let mut it = ( 0 ..5 ) . map ( |_| CountDrop :: new ( & count) ) . array_chunks :: < 3 > ( ) ;
17
+ let mut it = ( 0 ..5 ) . map ( |_| CountDrop :: new ( & count) ) . chunks :: < 3 > ( ) ;
18
18
assert_eq ! ( it. by_ref( ) . count( ) , 1 ) ;
19
19
assert_eq ! ( count. get( ) , 3 ) ;
20
20
let mut it2 = it. clone ( ) ;
@@ -27,62 +27,62 @@ fn test_iterator_array_chunks_clone_and_drop() {
27
27
}
28
28
29
29
#[ test]
30
- fn test_iterator_array_chunks_remainder ( ) {
31
- let mut it = ( 0 ..11 ) . array_chunks :: < 4 > ( ) ;
30
+ fn test_iterator_chunks_remainder ( ) {
31
+ let mut it = ( 0 ..11 ) . chunks :: < 4 > ( ) ;
32
32
assert_eq ! ( it. next( ) , Some ( [ 0 , 1 , 2 , 3 ] ) ) ;
33
33
assert_eq ! ( it. next( ) , Some ( [ 4 , 5 , 6 , 7 ] ) ) ;
34
34
assert_eq ! ( it. next( ) , None ) ;
35
35
assert_eq ! ( it. into_remainder( ) . unwrap( ) . as_slice( ) , & [ 8 , 9 , 10 ] ) ;
36
36
}
37
37
38
38
#[ test]
39
- fn test_iterator_array_chunks_size_hint ( ) {
40
- let it = ( 0 ..6 ) . array_chunks :: < 1 > ( ) ;
39
+ fn test_iterator_chunks_size_hint ( ) {
40
+ let it = ( 0 ..6 ) . chunks :: < 1 > ( ) ;
41
41
assert_eq ! ( it. size_hint( ) , ( 6 , Some ( 6 ) ) ) ;
42
42
43
- let it = ( 0 ..6 ) . array_chunks :: < 3 > ( ) ;
43
+ let it = ( 0 ..6 ) . chunks :: < 3 > ( ) ;
44
44
assert_eq ! ( it. size_hint( ) , ( 2 , Some ( 2 ) ) ) ;
45
45
46
- let it = ( 0 ..6 ) . array_chunks :: < 5 > ( ) ;
46
+ let it = ( 0 ..6 ) . chunks :: < 5 > ( ) ;
47
47
assert_eq ! ( it. size_hint( ) , ( 1 , Some ( 1 ) ) ) ;
48
48
49
- let it = ( 0 ..6 ) . array_chunks :: < 7 > ( ) ;
49
+ let it = ( 0 ..6 ) . chunks :: < 7 > ( ) ;
50
50
assert_eq ! ( it. size_hint( ) , ( 0 , Some ( 0 ) ) ) ;
51
51
52
- let it = ( 1 ..) . array_chunks :: < 2 > ( ) ;
52
+ let it = ( 1 ..) . chunks :: < 2 > ( ) ;
53
53
assert_eq ! ( it. size_hint( ) , ( usize :: MAX / 2 , None ) ) ;
54
54
55
- let it = ( 1 ..) . filter ( |x| x % 2 != 0 ) . array_chunks :: < 2 > ( ) ;
55
+ let it = ( 1 ..) . filter ( |x| x % 2 != 0 ) . chunks :: < 2 > ( ) ;
56
56
assert_eq ! ( it. size_hint( ) , ( 0 , None ) ) ;
57
57
}
58
58
59
59
#[ test]
60
- fn test_iterator_array_chunks_count ( ) {
61
- let it = ( 0 ..6 ) . array_chunks :: < 1 > ( ) ;
60
+ fn test_iterator_chunks_count ( ) {
61
+ let it = ( 0 ..6 ) . chunks :: < 1 > ( ) ;
62
62
assert_eq ! ( it. count( ) , 6 ) ;
63
63
64
- let it = ( 0 ..6 ) . array_chunks :: < 3 > ( ) ;
64
+ let it = ( 0 ..6 ) . chunks :: < 3 > ( ) ;
65
65
assert_eq ! ( it. count( ) , 2 ) ;
66
66
67
- let it = ( 0 ..6 ) . array_chunks :: < 5 > ( ) ;
67
+ let it = ( 0 ..6 ) . chunks :: < 5 > ( ) ;
68
68
assert_eq ! ( it. count( ) , 1 ) ;
69
69
70
- let it = ( 0 ..6 ) . array_chunks :: < 7 > ( ) ;
70
+ let it = ( 0 ..6 ) . chunks :: < 7 > ( ) ;
71
71
assert_eq ! ( it. count( ) , 0 ) ;
72
72
73
- let it = ( 0 ..6 ) . filter ( |x| x % 2 == 0 ) . array_chunks :: < 2 > ( ) ;
73
+ let it = ( 0 ..6 ) . filter ( |x| x % 2 == 0 ) . chunks :: < 2 > ( ) ;
74
74
assert_eq ! ( it. count( ) , 1 ) ;
75
75
76
- let it = iter:: empty :: < i32 > ( ) . array_chunks :: < 2 > ( ) ;
76
+ let it = iter:: empty :: < i32 > ( ) . chunks :: < 2 > ( ) ;
77
77
assert_eq ! ( it. count( ) , 0 ) ;
78
78
79
- let it = [ ( ) ; usize:: MAX ] . iter ( ) . array_chunks :: < 2 > ( ) ;
79
+ let it = [ ( ) ; usize:: MAX ] . iter ( ) . chunks :: < 2 > ( ) ;
80
80
assert_eq ! ( it. count( ) , usize :: MAX / 2 ) ;
81
81
}
82
82
83
83
#[ test]
84
- fn test_iterator_array_chunks_next_and_next_back ( ) {
85
- let mut it = ( 0 ..11 ) . array_chunks :: < 3 > ( ) ;
84
+ fn test_iterator_chunks_next_and_next_back ( ) {
85
+ let mut it = ( 0 ..11 ) . chunks :: < 3 > ( ) ;
86
86
assert_eq ! ( it. next( ) , Some ( [ 0 , 1 , 2 ] ) ) ;
87
87
assert_eq ! ( it. next_back( ) , Some ( [ 6 , 7 , 8 ] ) ) ;
88
88
assert_eq ! ( it. next( ) , Some ( [ 3 , 4 , 5 ] ) ) ;
@@ -94,8 +94,8 @@ fn test_iterator_array_chunks_next_and_next_back() {
94
94
}
95
95
96
96
#[ test]
97
- fn test_iterator_array_chunks_rev_remainder ( ) {
98
- let mut it = ( 0 ..11 ) . array_chunks :: < 4 > ( ) ;
97
+ fn test_iterator_chunks_rev_remainder ( ) {
98
+ let mut it = ( 0 ..11 ) . chunks :: < 4 > ( ) ;
99
99
{
100
100
let mut it = it. by_ref ( ) . rev ( ) ;
101
101
assert_eq ! ( it. next( ) , Some ( [ 4 , 5 , 6 , 7 ] ) ) ;
@@ -107,17 +107,17 @@ fn test_iterator_array_chunks_rev_remainder() {
107
107
}
108
108
109
109
#[ test]
110
- fn test_iterator_array_chunks_try_fold ( ) {
110
+ fn test_iterator_chunks_try_fold ( ) {
111
111
let count = Cell :: new ( 0 ) ;
112
- let mut it = ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . array_chunks :: < 3 > ( ) ;
112
+ let mut it = ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . chunks :: < 3 > ( ) ;
113
113
let result: Result < _ , ( ) > = it. by_ref ( ) . try_fold ( 0 , |acc, _item| Ok ( acc + 1 ) ) ;
114
114
assert_eq ! ( result, Ok ( 3 ) ) ;
115
115
assert_eq ! ( count. get( ) , 9 ) ;
116
116
drop ( it) ;
117
117
assert_eq ! ( count. get( ) , 10 ) ;
118
118
119
119
let count = Cell :: new ( 0 ) ;
120
- let mut it = ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . array_chunks :: < 3 > ( ) ;
120
+ let mut it = ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . chunks :: < 3 > ( ) ;
121
121
let result = it. by_ref ( ) . try_fold ( 0 , |acc, _item| if acc < 2 { Ok ( acc + 1 ) } else { Err ( acc) } ) ;
122
122
assert_eq ! ( result, Err ( 2 ) ) ;
123
123
assert_eq ! ( count. get( ) , 9 ) ;
@@ -126,8 +126,8 @@ fn test_iterator_array_chunks_try_fold() {
126
126
}
127
127
128
128
#[ test]
129
- fn test_iterator_array_chunks_fold ( ) {
130
- let result = ( 1 ..11 ) . array_chunks :: < 3 > ( ) . fold ( 0 , |acc, [ a, b, c] | {
129
+ fn test_iterator_chunks_fold ( ) {
130
+ let result = ( 1 ..11 ) . chunks :: < 3 > ( ) . fold ( 0 , |acc, [ a, b, c] | {
131
131
assert_eq ! ( acc + 1 , a) ;
132
132
assert_eq ! ( acc + 2 , b) ;
133
133
assert_eq ! ( acc + 3 , c) ;
@@ -137,24 +137,24 @@ fn test_iterator_array_chunks_fold() {
137
137
138
138
let count = Cell :: new ( 0 ) ;
139
139
let result =
140
- ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . array_chunks :: < 3 > ( ) . fold ( 0 , |acc, _item| acc + 1 ) ;
140
+ ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . chunks :: < 3 > ( ) . fold ( 0 , |acc, _item| acc + 1 ) ;
141
141
assert_eq ! ( result, 3 ) ;
142
142
// fold impls may or may not process the remainder
143
143
assert ! ( count. get( ) <= 10 && count. get( ) >= 9 ) ;
144
144
}
145
145
146
146
#[ test]
147
- fn test_iterator_array_chunks_try_rfold ( ) {
147
+ fn test_iterator_chunks_try_rfold ( ) {
148
148
let count = Cell :: new ( 0 ) ;
149
- let mut it = ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . array_chunks :: < 3 > ( ) ;
149
+ let mut it = ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . chunks :: < 3 > ( ) ;
150
150
let result: Result < _ , ( ) > = it. try_rfold ( 0 , |acc, _item| Ok ( acc + 1 ) ) ;
151
151
assert_eq ! ( result, Ok ( 3 ) ) ;
152
152
assert_eq ! ( count. get( ) , 9 ) ;
153
153
drop ( it) ;
154
154
assert_eq ! ( count. get( ) , 10 ) ;
155
155
156
156
let count = Cell :: new ( 0 ) ;
157
- let mut it = ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . array_chunks :: < 3 > ( ) ;
157
+ let mut it = ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . chunks :: < 3 > ( ) ;
158
158
let result = it. try_rfold ( 0 , |acc, _item| if acc < 2 { Ok ( acc + 1 ) } else { Err ( acc) } ) ;
159
159
assert_eq ! ( result, Err ( 2 ) ) ;
160
160
assert_eq ! ( count. get( ) , 9 ) ;
@@ -163,8 +163,8 @@ fn test_iterator_array_chunks_try_rfold() {
163
163
}
164
164
165
165
#[ test]
166
- fn test_iterator_array_chunks_rfold ( ) {
167
- let result = ( 1 ..11 ) . array_chunks :: < 3 > ( ) . rfold ( 0 , |acc, [ a, b, c] | {
166
+ fn test_iterator_chunks_rfold ( ) {
167
+ let result = ( 1 ..11 ) . chunks :: < 3 > ( ) . rfold ( 0 , |acc, [ a, b, c] | {
168
168
assert_eq ! ( 10 - ( acc + 1 ) , c) ;
169
169
assert_eq ! ( 10 - ( acc + 2 ) , b) ;
170
170
assert_eq ! ( 10 - ( acc + 3 ) , a) ;
@@ -174,7 +174,7 @@ fn test_iterator_array_chunks_rfold() {
174
174
175
175
let count = Cell :: new ( 0 ) ;
176
176
let result =
177
- ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . array_chunks :: < 3 > ( ) . rfold ( 0 , |acc, _item| acc + 1 ) ;
177
+ ( 0 ..10 ) . map ( |_| CountDrop :: new ( & count) ) . chunks :: < 3 > ( ) . rfold ( 0 , |acc, _item| acc + 1 ) ;
178
178
assert_eq ! ( result, 3 ) ;
179
179
assert_eq ! ( count. get( ) , 10 ) ;
180
180
}
0 commit comments