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
use Widget;
/// Represents a collection of widgets.
///
///
/// # Example usage
///
/// ## Widget tuple
///
/// Most often you will use [`WidgetList`] in a form of a tuple:
///
/// ```
/// Column::builder()
/// .children((WidgetA, WidgetB, WidgetC));
/// ```
///
/// This pattern is great if you have a statically known list of widgets, since
/// each child widget can have different types.
///
/// Do note that currently only tuples with less than 50 widgets work, but in
/// the future this limit might be increased / lifted.
///
/// ## Widget vector / array / slice
///
/// If tuple pattern doesn't make it for you, you can also use vector, array
/// and slice as [`WidgetList`]. Those come with their respectful constraints,
/// like e.g. type stored in that collection must be the same - you can't have
/// widgets of different types, unless you box / type erase them:
///
/// ```
/// Column::builder()
/// .children(&widgets_a); // &[WidgetA]
/// Column::builder()
/// .children([WidgetB, WidgetB, WidgetB]); // [WidgetB]
/// Column::builder()
/// .children(vec![WidgetC, WidgetC, WidgetC]); // Vec<WidgetC>
///
/// // And type erased, e.g.:
/// Column::builder()
/// .children([
/// Box::new(WidgetA) as Box<dyn Widget>,
/// Box::new(WidgetB),
/// Box::new(WidgetC),
/// ]); // [Box<dyn Widget>]
/// Column::builder()
/// .children(vec![
/// &widget_a as &dyn Widget,
/// &widget_b,
/// &widget_c,
/// ]); // Vec<&dyn Widget>
/// ```
impl_widget_list!;