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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//! Ergonomic iterator collection methods.
//!
//! This module provides extension traits that add shorthand collection methods to iterators,
//! eliminating the need for turbofish syntax when the target collection type is known.
//!
//! Instead of writing `.collect::<Vec<_>>()`, you can simply call `.covec()`. This improves
//! readability in iterator chains where the collection type is a minor detail rather than
//! the focus of the expression.
//!
//! # Available Methods
//!
//! | Method | Collects into | Equivalent to |
//! |-------------|-------------------|----------------------------------|
//! | `.covec()` | [`Vec<T>`] | `.collect::<Vec<_>>()` |
//! | `.cosvec()` | [`SmallVec<T>`] | `.collect::<SmallVec<_>>()` |
//! | `.codeque()`| [`VecDeque<T>`] | `.collect::<VecDeque<_>>()` |
//!
//! # Example
//!
//! ```rust,no_run
//! # use zhc_utils::iter::CollectInVec;
//! let squares = (1..=5).map(|x| x * x).covec();
//! assert_eq!(squares, vec![1, 4, 9, 16, 25]);
//! ```
//!
//! [`SmallVec<T>`]: crate::small::SmallVec
use VecDeque;
use crateSmallVec;
/// Extension trait for collecting iterator elements into a [`Vec`].
///
/// This trait is automatically implemented for all iterators, providing the [`covec`](Self::covec)
/// method as a concise alternative to `.collect::<Vec<_>>()`.
/// Extension trait for collecting iterator elements into a [`SmallVec`].
///
/// This trait is automatically implemented for all iterators, providing the
/// [`cosvec`](Self::cosvec) method as a concise alternative to `.collect::<SmallVec<_>>()`.
///
/// [`SmallVec`]: crate::small::SmallVec
/// Extension trait for collecting iterator elements into a [`VecDeque`].
///
/// This trait is automatically implemented for all iterators, providing the
/// [`codeque`](Self::codeque) method as a concise alternative to `.collect::<VecDeque<_>>()`.