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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
use HashMap;
/// Tries to convert a [`IntoIterator`] into a container that may fail to be constructed.
///
/// This trait is similar to [`FromIterator`], but can uphold a containers invariant and
/// returns an [`Err`] if it would be violated. And like with [`Iterator::collect`],
/// containers implementing this trait can be collected into via
/// [`TryCollectEx::try_collect_ex`].
///
/// Implementations may rely on [`Iterator::size_hint`] providing reliable bounds for the
/// number of elements in the iterator in order to optimize their implementations. A size hint
/// that provides incorrect bounds may cause panics, produce incorrect results, or produce a
/// result that violates container constraints, but must not result in undefined behavior.
///
/// Implementations are encouraged to return all the data consumed by the iterator, as well
/// as the partially consumed iterator on an error, but are not required to do so.
/// Extends [Iterator] with a failable collect method.
///
/// This trait allows an iterator to return any collection that can be created via
/// [`TryFromIterator`], similar to [`Iterator::collect`] and [`FromIterator::from_iter`],
/// but with the ability to return a implementation specific error if the creation of the contaienr
/// fails some invariant.