Skip to content

Commit 0c78500

Browse files
committed
library/core/tests/iter documentation and cleanup
1 parent bc830a2 commit 0c78500

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

library/core/tests/iter/mod.rs

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
//! Note
2+
//! ----
3+
//! You're probably viewing this file because you're adding a test (or you might
4+
//! just be browsing, in that case, hey there!).
5+
//!
6+
//! The iter test suite is split into two big modules, and some miscellaneous
7+
//! smaller modules. The two big modules are `adapters` and `traits`.
8+
//!
9+
//! `adapters` are for methods on `Iterator` that adapt the data inside the
10+
//! iterator, whether it be by emitting another iterator or returning an item
11+
//! from inside the iterator after executing a closure on each item.
12+
//!
13+
//! `traits` are for trait's that extend an `Iterator` (and the `Iterator`
14+
//! trait itself, mostly containing miscellaneous methods). For the most part,
15+
//! if a test in `traits` uses a specific adapter, then it should be moved to
16+
//! that adapter's test file in `adapters`.
17+
118
mod adapters;
219
mod range;
320
mod sources;

library/core/tests/iter/traits/collect.rs

-6
This file was deleted.

library/core/tests/iter/traits/double_ended.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
//! Note
2+
//! ----
3+
//! You're probably viewing this file because you're adding a test (or you might
4+
//! just be browsing, in that case, hey there!).
5+
//!
6+
//! If you've made a test that happens to use one of DoubleEnded's methods, but
7+
//! it tests another adapter or trait, you should *add it to the adapter or
8+
//! trait's test file*.
9+
//!
10+
//! Some examples would be `adapters::cloned::test_cloned_try_folds` or
11+
//! `adapters::flat_map::test_double_ended_flat_map`, which use `try_fold` and
12+
//! `next_back`, but test their own adapter.
13+
114
#[test]
215
fn test_iterator_rev_nth_back() {
316
let v: &[_] = &[0, 1, 2, 3, 4];

library/core/tests/iter/traits/iterator.rs

+7
Original file line numberDiff line numberDiff line change
@@ -461,3 +461,10 @@ fn test_iterator_len() {
461461
assert_eq!(v[..10].iter().count(), 10);
462462
assert_eq!(v[..0].iter().count(), 0);
463463
}
464+
465+
#[test]
466+
fn test_collect() {
467+
let a = vec![1, 2, 3, 4, 5];
468+
let b: Vec<isize> = a.iter().cloned().collect();
469+
assert!(a == b);
470+
}

library/core/tests/iter/traits/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
mod accum;
2-
mod collect;
32
mod double_ended;
43
mod iterator;
54
mod step;

0 commit comments

Comments
 (0)