pub fn seq(layout: Box<Layout>) -> Box<Layout>Expand description
Wraps a layout for sequential breaking behavior.
The seq constructor creates a sequence where if any composition within
the sequence breaks, then all subsequent compositions in the sequence also
break. This creates a “cascading” break effect useful for statement lists,
block structures, or any content where breaking should propagate forward.
§Parameters
layout- The layout to treat as a breaking sequence
§Returns
A boxed Layout::Seq that implements sequential breaking.
§Examples
use typeset::*;
// Sequential breaking for statement-like structures
let statements = seq(join_with_lines(vec![
comp(text_str("let x = "), text_str("value1;"), true, false),
comp(text_str("let y = "), text_str("value2;"), true, false),
comp(text_str("let z = "), text_str("value3;"), true, false)
]));
// If one statement needs to break due to width constraints,
// all following statements will also break, creating:
// let x =
// value1;
// let y =
// value2;
// let z =
// value3;§Behavior
- Breaking propagates forward through the sequence
- Earlier elements can stay unbroken even if later ones break
- Useful for maintaining consistent indentation in code blocks
- Different from
grpwhich breaks all-or-nothing
§See Also
grp- For all-or-nothing group breaking- [
line()] - For explicit line breaks - [
join_with_lines] - Often used with seq for statement sequences