Skip to main content

TableOrder

Struct TableOrder 

Source
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

Source

pub(super) fn of(root: &mut Table) -> Self

Plan the order of every table under root, including root.

Source

const fn place_root_first(slots: &mut [Slot], has_values: bool)

The root has no header, so it only prints when it holds values.

Source

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.

Source

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.

Source

fn subtree_end(slots: &[Slot], index: usize) -> usize

The walk index after the last descendant of the table at index.

Source

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.

Source

fn prints_before(slots: &[Slot], order: &[usize], rank: usize) -> bool

Whether any table or value before rank prints a line.

Source

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.

Source

pub(super) fn forget(item: &mut Item)

Drop the positions of every table in item. Positions that come from another document mean nothing in this one.

Source

fn walk( table: &mut Table, depth: usize, visit: &mut impl FnMut(&mut Table, usize), )

Visit table and every table below it, parents first. Dotted tables have no header and no position, so they are only descended into.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.