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
use types;
use crateGlobal;
/// An [`EcoVec`](types::EcoVec) that defaults to the [`Global`] allocator.
///
/// The allocator type parameter defaults to [`Global`] so that the common
/// `EcoVec<T>` spelling keeps working in type position (e.g. `EcoVec<u8>`),
/// while method calls without an explicit allocator (`EcoVec::with_capacity`,
/// `eco_vec![..]`) infer `A = Global` through the alias — mirroring the
/// non-allocator-api build's `EcoVec<T>` alias.
pub type EcoVec<T, A = Global> = EcoVec;
/// Create a new [`EcoVec`] with the given elements.
/// ```
/// # use turbocow::eco_vec;
/// assert_eq!(eco_vec![1; 4], [1; 4]);
/// assert_eq!(eco_vec![1, 2, 3], [1, 2, 3]);
/// ```
///
/// Optionally, you can specify an allocator to use. (This example uses
/// [`bump_scope::Bump`], whose `Allocator` impl is wired up under the
/// `allocator-api2-v02` feature.)
/// ```
/// # use turbocow::eco_vec;
/// # use bump_scope::Bump;
/// let allocator: Bump = Bump::new();
/// assert_eq!(eco_vec![in &allocator; 1; 4], [1; 4]);
/// assert_eq!(eco_vec![in &allocator; 1, 2, 3], [1, 2, 3]);
/// ```