We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 425aefb commit ae39957Copy full SHA for ae39957
library/alloc/src/collections/vec_deque/tests.rs
@@ -1269,6 +1269,28 @@ fn extract_if_true() {
1269
assert_eq!(list, vec![]);
1270
}
1271
1272
+#[test]
1273
+fn extract_if_non_contiguous() {
1274
+ let mut list =
1275
+ [1, 2, 4, 6, 7, 9, 11, 13, 15, 17, 18, 20, 22, 24, 26, 27, 29, 31, 33, 34, 35, 36, 37, 39]
1276
+ .into_iter()
1277
+ .collect::<VecDeque<_>>();
1278
+ list.rotate_left(3);
1279
+
1280
+ assert!(!list.is_contiguous());
1281
+ assert_eq!(
1282
+ list,
1283
+ [6, 7, 9, 11, 13, 15, 17, 18, 20, 22, 24, 26, 27, 29, 31, 33, 34, 35, 36, 37, 39, 1, 2, 4]
1284
+ );
1285
1286
+ let removed = list.extract_if(.., |x| *x % 2 == 0).collect::<Vec<_>>();
1287
+ assert_eq!(removed.len(), 10);
1288
+ assert_eq!(removed, vec![6, 18, 20, 22, 24, 26, 34, 36, 2, 4]);
1289
1290
+ assert_eq!(list.len(), 14);
1291
+ assert_eq!(list, vec![7, 9, 11, 13, 15, 17, 27, 29, 31, 33, 35, 37, 39, 1]);
1292
+}
1293
1294
#[test]
1295
fn extract_if_complex() {
1296
{
0 commit comments