Enum spirt::print::pretty::Node

source ·
pub enum Node {
    Text(Option<Styles>, Cow<'static, str>),
    Anchor {
        is_def: bool,
        anchor: Rc<str>,
        text: Box<[(Option<Styles>, Cow<'static, str>)]>,
    },
    IndentedBlock(Vec<Fragment>),
    InlineOrIndentedBlock(Vec<Fragment>),
    BreakingOnlySpace,
    ForceLineSeparation,
    IfBlockLayout(&'static str),
}

Variants§

§

Text(Option<Styles>, Cow<'static, str>)

§

Anchor

Fields

§is_def: bool
§anchor: Rc<str>
§text: Box<[(Option<Styles>, Cow<'static, str>)]>

Anchor (HTML <a href="#...">, optionally with id="..." when is_def), using Node::Text-like “styled text” nodes for its text contents.

§

IndentedBlock(Vec<Fragment>)

Container for Fragments, using block layout (indented on separate lines).

§

InlineOrIndentedBlock(Vec<Fragment>)

Container for Fragments, either using inline layout (all on one line) or block layout (indented on separate lines).

§

BreakingOnlySpace

Require that nodes before and after this node, are separated by some whitespace (either by a single space, or by being on different lines).

This is similar in effect to a Text(" "), except that it doesn’t add leading/trailing spaces when found at the start/end of a line, as the adjacent \n is enough of a “breaking space”.

Conversely, Text(" ") can be considered a “non-breaking space” (NBSP).

§

ForceLineSeparation

Require that nodes before and after this node, go on different lines.

This is similar in effect to a Text("\n"), except that it doesn’t introduce a new \n when the previous/next node(s) already end/start on a new line (whether from Text("\n") or another ForceLineStart).

§

IfBlockLayout(&'static str)

Implementations§

source§

impl Node

source

fn approx_rigid_layout(&self) -> ApproxLayout

Determine the “rigid” component of the ApproxLayout of this Node.

That is, this accounts for the parts of the Node that don’t depend on contextual sizing, i.e. MaxWidths (see also approx_flex_layout).

source

fn approx_flex_layout(&mut self, max_widths: MaxWidths) -> ApproxLayout

Determine the “flexible” component of the ApproxLayout of this Node, potentially making adjustments in order to fit within max_widths.

That is, this accounts for the parts of the Node that do depend on contextual sizing, i.e. MaxWidths (see also approx_rigid_layout).

source§

impl Node

source

fn render_to_line_ops( &self, directly_in_block: bool ) -> impl InternalIterator<Item = LineOp<'_>>

Flatten the Node to LineOps.

source

fn render_to_line_ops_try_for_each_helper<'a, T>( &'a self, directly_in_block: bool, each_line_op: impl FnMut(LineOp<'a>) -> ControlFlow<T> ) -> ControlFlow<T>

Trait Implementations§

source§

impl Clone for Node

source§

fn clone(&self) -> Node

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl From<&'static str> for Node

source§

fn from(text: &'static str) -> Self

Converts to this type from the input type.
source§

impl From<String> for Node

source§

fn from(text: String) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Node

source§

fn eq(&self, other: &Node) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Node

Auto Trait Implementations§

§

impl RefUnwindSafe for Node

§

impl !Send for Node

§

impl !Sync for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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>,

§

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.