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
/// Creates a [`DisjointSetVec<T>`] containing the specified elements as separate singletons, not joined to each other.
///
/// `disjoint_set_vec!` allows a `DisjointSetVec<T>` to be defined with the same syntax as array expressions.
/// There are two forms of this macro:
///
/// - Create a `DisjointSetVec<T>` containing a given list of elements:
///
/// ```
/// use disjoint::disjoint_set_vec;
///
/// let ds = disjoint_set_vec!['a', 'b'];
/// assert_eq!(ds[0], 'a');
/// assert_eq!(ds[1], 'b');
/// assert!(!ds.is_joined(0, 1));
/// ```
///
/// - Create a `DisjointSetVec<T>` from a given element and size:
///
/// ```
/// use disjoint::disjoint_set_vec;
///
/// let ds = disjoint_set_vec![1; 3];
/// assert_eq!(*ds.values(), [1, 1, 1]);
/// assert!(!ds.is_joined(0, 2));
/// ```
///
/// Note that unlike array expressions, this syntax supports all elements
/// which implement [`Clone`] and the number of elements doesn't have to be
/// a constant.
///
/// This will use `clone` to duplicate an expression, so one should be careful
/// using this with types having a non-standard `Clone` implementation. For
/// example, `disjoint_set_vec![Rc::new(1); 5]` will create five references
/// to the same boxed integer value, not five references pointing to independently
/// boxed integers.
///
/// Also, note that `disjoint_set_vec![expr; 0]` is allowed, and produces an empty container.
/// This will still evaluate `expr`, however, and immediately drop the resulting value, so
/// be mindful of side effects.
///
/// [`DisjointSetVec<T>`]: crate::DisjointSetVec