pub fn split_v_n<const N: usize>(
area: Rect,
constraints: [Constraint; N],
) -> [Rect; N]Expand description
Split area into stacked rows top-to-bottom, like split_v, but sized to a compile-time
pane count N: takes [Constraint; N] and returns [Rect; N] instead of allocating a Vec.
The array length ties the constraint count to the return type, so a caller that destructures
the result (let [header, body, footer] = split_v_n(area, [..]);) gets a compile error if it
adds or removes a constraint without updating the destructuring pattern, rather than a
silently out-of-sync index into a Vec. Never allocates, for any N.
Never panics, for the same reason as split_v.
ยงExamples
use retroglyph_core::grid::Rect;
use retroglyph_ui::{Constraint, split_v_n};
let area = Rect::new(0, 0, 20, 10);
let [header, body, footer] =
split_v_n(area, [Constraint::Fixed(1), Constraint::Fill(1), Constraint::Fixed(1)]);
assert_eq!((header.height(), body.height(), footer.height()), (1, 8, 1));