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
/// Creates a [`SmallVec`] containing the arguments.
///
/// `small_vec!` macro allows creation of a `SmallVec` using syntax similar to that of the standard
/// array.
///
/// # Examples
///
/// 1. `small_vec![CAPACITY; TYPE]` - create an empty `SmallVec` with given local capacity and
/// element type:
///
/// ```rust
/// # use cds::small_vec;
/// let v = small_vec![3; u64];
/// assert_eq!(v.capacity(), 3);
/// assert_eq!(v.is_empty(), true);
/// assert_eq!(v.is_heap(), false);
/// ```
///
/// 2. `small_vec![CAPACITY; TYPE; ELEM+]` - create a `SmallVec` with given local capacity,
/// element type and element values:
///
/// ```rust
/// # use cds::small_vec;
/// let v = small_vec![5; u64; 17];
/// assert_eq!(v.capacity(), 5);
/// assert_eq!(v.len(), 1);
/// assert_eq!(v[0], 17u64);
/// ```
///
/// 3. `small_vec![CAPACITY;]` - create an empty `SmallVec` with given local capacity,
/// let the compiler derive the element type:
///
/// ```rust
/// # use cds::small_vec;
/// let mut v = small_vec![3;];
/// v.push("str");
/// assert_eq!(v.capacity(), 3);
/// assert_eq!(v.len(), 1);
/// assert_eq!(v[0], "str");
/// ```
///
/// 4. `small_vec![CAPACITY; ELEM+]` - create a `SmallVec` with given local capacity and elements,
/// let the compiler derive the element type:
///
/// ```rust
/// # use cds::small_vec;
/// let v = small_vec![32; 9, 8, 7];
/// assert_eq!(v.capacity(), 32);
/// assert_eq!(v.len(), 3);
/// assert_eq!(&v[..], &[9, 8, 7]);
/// ```
///
/// # Panics
///
/// The macro panics if non-empty small-vector is created and dynamic memory allocation fails.
/// See [`SmallVec::reserve_exact`] for more information.
///
/// [`SmallVec`]: crate::smallvec::SmallVec
/// [`SmallVec::reserve_exact`]: crate::smallvec::SmallVec::reserve_exact