1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use crateCollectError;
use crateCollision;
/// Specialization of [`CollectError`] for [`Collision`].
///
/// This type is used when collection fails due to a collision. Such as a
/// duplicate key in a map or set. The [`Collision`] will contain the item
/// that collided during collection.
///
/// # Type Parameters
///
/// - `I`: The type of the [Iterator] that was used to iterate the values.
/// - `C`: The type of the collection that was used to collect the values.
///
/// # Data Recovery
///
/// If `C` implements [`IntoIterator`], this type implements [`IntoIterator`],
/// as well, allowing the data in the original iterator to be reconstructed from
/// [`CollectError::remain`], [`CollectError::collected`], and the colliding item.
///
/// # Examples
///
/// ```rust
/// # use collect_failable::errors::CollectError;
/// # use collect_failable::errors::collision::Collision;
/// # use std::collections::HashSet;
/// let error = CollectError::<_, HashSet<_>, _>::collision(1..=1, HashSet::from([1]), 1);
///
/// let values = error.into_iter().collect::<Vec<_>>();
///
/// assert_eq!(values.len(), 3, "Should have 3 values");
/// assert!(values.iter().all(|v| v == &1), "Should only contain 1");
/// ```