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
pub trait WithCapacity {
type Input;
fn with_capacity(input: Self::Input) -> Self;
}
#[cfg(feature = "alloc")]
impl<T> WithCapacity for alloc::vec::Vec<T> {
type Input = usize;
fn with_capacity(input: Self::Input) -> Self {
alloc::vec::Vec::with_capacity(input)
}
}
#[cfg(feature = "with_arrayvec")]
impl<T, const N: usize> WithCapacity for arrayvec::ArrayVec<crate::ArrayWrapper<T, N>> {
type Input = usize;
fn with_capacity(_: Self::Input) -> Self {
arrayvec::ArrayVec::new()
}
}
#[cfg(feature = "with_smallvec")]
impl<T, const N: usize> WithCapacity for smallvec::SmallVec<crate::ArrayWrapper<T, N>> {
type Input = usize;
fn with_capacity(input: Self::Input) -> Self {
smallvec::SmallVec::with_capacity(input)
}
}
#[cfg(feature = "with_staticvec")]
impl<T, const N: usize> WithCapacity for staticvec::StaticVec<T, N> {
type Input = usize;
fn with_capacity(_: Self::Input) -> Self {
staticvec::StaticVec::new()
}
}