pub(super) struct TableOrder(Vec<Slot>);Expand description
The positions the tables of a merged tree get.
Existing tables keep their relative source order. A table without a position is new and goes after the last table of its parent’s subtree, so it ends up at the end of its parent.
Tuple Fields§
§0: Vec<Slot>Implementations§
Source§impl TableOrder
impl TableOrder
Sourcepub(super) fn of(root: &mut Table) -> Self
pub(super) fn of(root: &mut Table) -> Self
Plan the order of every table under root, including root.
Sourceconst fn place_root_first(slots: &mut [Slot], has_values: bool)
const fn place_root_first(slots: &mut [Slot], has_values: bool)
The root has no header, so it only prints when it holds values.
Sourcefn ordered(slots: &[Slot]) -> Vec<usize>
fn ordered(slots: &[Slot]) -> Vec<usize>
Walk indices in final order: existing tables by old position, then every new table after the last table of its parent’s subtree.
Sourcefn slot_after_subtree(slots: &[Slot], order: &[usize], index: usize) -> usize
fn slot_after_subtree(slots: &[Slot], order: &[usize], index: usize) -> usize
The place for the new table at index. It goes right before its own
first existing descendant. Without one, it goes after the last table
of its parent’s subtree. The root goes to the front.
Sourcefn subtree_end(slots: &[Slot], index: usize) -> usize
fn subtree_end(slots: &[Slot], index: usize) -> usize
The walk index after the last descendant of the table at index.
Sourcefn needs_blank(slots: &[Slot], order: &[usize], rank: usize) -> bool
fn needs_blank(slots: &[Slot], order: &[usize], rank: usize) -> bool
Whether the table at rank needs a blank line before its decor. That
holds for an existing table that directly follows a new table that
prints a header, other than the root. It also holds for a new table
that brings a comment, which replaces the blank line a table gets by
default, when something is printed before it.
Sourcefn prints_before(slots: &[Slot], order: &[usize], rank: usize) -> bool
fn prints_before(slots: &[Slot], order: &[usize], rank: usize) -> bool
Whether any table or value before rank prints a line.
Sourcepub(super) fn apply(&self, root: &mut Table)
pub(super) fn apply(&self, root: &mut Table)
Number the tables under root, which must be the tree this order was
planned for, and separate a header that follows a new one by a blank
line.