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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
//! Inline table support for embedding nested tables beneath rows of a parent table.
//!
//! An [`InlineTable`] acts as a nested table rendered directly below a specific row in the outer [`Table`].
//! It automatically inherits the parent table's border styles and column separators,
//! while maintaining its own column structure, headers, rows, and constraints.
//!
//! Because `InlineTable` implements [`Deref`] and [`DerefMut`] targeting [`Table`], you can use
//! all familiar table configuration methods ([`Table::set_header`], [`Table::add_row`], etc.) directly
//! on an `InlineTable`.
//!
//! # Best Practice: Inside-Out Composition
//!
//! When working with inline tables—especially when creating multi-level nested tables—the
//! recommended approach is to define tables **inside-out** (bottom-up):
//!
//! 1. Define and populate the innermost [`InlineTable`] instances with their columns, headers, and rows.
//! 2. Combine them into higher-level inline tables or sections using [`Table::add_inline_table`].
//! 3. Finally, assemble the outer [`Table`], adding rows and attaching the prepared inline tables.
//!
//! This modular pattern keeps table logic clean, prevents scope confusion, and ensures clear data flow.
//!
//! # Example
//!
//! ```
//! use comfy_table::{InlineTable, Table};
//!
//! // 1. Define the innermost nested table first
//! let mut inner_table = InlineTable::new();
//! inner_table
//! .set_header(vec!["Component", "Latency", "Status"])
//! .add_row(vec!["Cache Tier", "0.4 ms", "Healthy"])
//! .add_row(vec!["Storage Tier", "2.1 ms", "Healthy"]);
//!
//! // 2. Define the intermediate section and attach the inner table
//! let mut service_section = InlineTable::new();
//! service_section
//! .set_header(vec!["Service", "Region"])
//! .add_row(vec!["Authentication API", "eu-central-1"])
//! .add_inline_table(inner_table);
//!
//! // 3. Assemble the outer table
//! let mut outer = Table::new();
//! outer
//! .set_header(vec!["Cluster", "Environment"])
//! .add_row(vec!["Production-Core", "Live"])
//! .add_inline_table(service_section)
//! .add_row(vec!["Staging-Core", "Idle"]);
//!
//! println!("{outer}");
//! ```
use ;
use crate::;
/// A nested table designed to be embedded inline directly below a row within a parent [`Table`].
///
/// `InlineTable` wraps an inner [`Table`] and tracks its placement relative to the rows of the
/// parent table. It implements [`Deref`] and [`DerefMut`] targeting [`Table`], allowing full access
/// to all table configuration methods (such as [`Table::set_header`], [`Table::add_row`],
/// [`Table::set_constraints`], etc.).
///
/// When added to a parent table via [`Table::add_inline_table`], it is rendered below the most recently
/// added row and inherits the outer table's styling for consistent appearance.
///
/// # Best Practice: Inside-Out Construction
///
/// It is recommended to construct tables **inside-out** (bottom-up):
/// 1. Define and populate the innermost [`InlineTable`] instances first.
/// 2. Nest them into intermediate inline tables via [`Table::add_inline_table`].
/// 3. Finally, assemble the outer [`Table`].
///
/// # Example
///
/// ```
/// use comfy_table::{InlineTable, Table};
///
/// let mut inline = InlineTable::new();
/// inline.set_header(vec!["Sub", "Entry"]);
/// inline.add_row(vec!["Nested", "Value"]);
///
/// let mut table = Table::new();
/// table.add_row(vec!["Main", "Row"]);
/// table.add_inline_table(inline);
/// ```