Config

Struct Config 

Source
pub struct Config { /* private fields */ }
Expand description

Configuration used by a Generator to control the layout algorithm.

For style configuration with a built-in diagram writer, see the Style struct.

Implementations§

Source§

impl Config

Source

pub const fn new() -> Self

Initialize using default values.

This is a const function which is identical to the Default implementation.

Source

pub fn generator<V, R>(self, root: V, ramifier: R) -> Generator<V, R>

Construct a generator using this configuration, starting at the provided root and with the given ramifier.

This is a convenience wrapper around Generator::with_config.

Source

pub const fn row_padding(self, pad: usize) -> Self

The number of extra rows to use as padding between vertices.

The padding applies after the annotation, or after the vertex if there is no annotation.

The default is 0.

§Example

Here is an example going from a row padding of 0 to 1.

 0         0
 ├┬╮       ├┬╮
 │1├╮      │1├╮
 ││2│      ││││
 │3│├╮  →  ││2│
 │╭╯││     ││││
 ││╭┤│     │3│├╮
 │││4│     │╭╯││
 ││5╭╯  →  ││╭┤│
 │6╭╯      │││4│
 7╭╯       │││╭╯
  8        ││5│
           ││╭╯
           │6│
           │╭╯
           7│
           ╭╯
           8
Source

pub const fn minimize_width(self, minimize: bool) -> Self

Whether to minimize the width.

If set, the preparation rows between vertex markers will also remove all internal whitespace. This almost always makes the branch diagram taller.

The default value is false.

§Example

Here is an example minimizing the width.

 0         0
 ├┬╮       ├┬╮
 │1├╮      │1├╮
 ││2│      ││2│
 │3│├╮  →  │3│├╮
 │╭╯││     │╭╯││
 ││╭┤│     ││╭┤│
 │││4│     │││4│
 ││5╭╯  →  │││╭╯
 │6╭╯      ││5│
 7╭╯       ││╭╯
  8        │6│
           │╭╯
           7│
           ╭╯
           8
Source

pub const fn annotation_before_vertex(self, before: bool) -> Self

Write the vertex on the last row of the annotation instead of the first.

This is mostly useful for writing the tree with the root at the bottom.

This can result in slightly taller branch diagrams. In particular, even if you are writing in inverted mode, if your annotations occupy at most one line, it can be useful to keep this as false anyway.

The default value is false.

§Example

Here is an example writing the annotation before the vertex.

0             0
├┬╮           ├┬╮
│1├╮ L0   →   ││├╮ L0
││││ L1       │1││ L1
││2│          ││2│
│3│├╮ L0  →   │3│├╮ L0
│╭╯││         │╭╯││
││╭┤│         ││╭┤│
│││4│ L0  →   │││││ L0
│││╭╯ L1      │││││ L1
││││  L2      │││4│ L2
││5│          ││5╭╯
│6╭╯          │6╭╯
7╭╯           7╭╯
 8             8
Source

pub const fn reverse_annotation_lines(self, rev: bool) -> Self

Write the annotation lines in reverse order.

This is mostly useful for writing the tree with the root at the bottom.

The default value is false.

§Example

Here is an example writing the annotation lines in reverse order.

0            0       
├┬╮          ├┬╮     
│1├╮ L0   →  │1├╮ L1
││││ L1      ││││ L0
││2│         ││2│    
│3│├╮ L0  →  │3│├╮ L0
│╭╯││        │╭╯││   
││╭┤│        ││╭┤│   
│││4│ L0  →  │││4│ L2
│││╭╯ L1     │││╭╯ L1
││││  L2     ││││  L0
││5│         ││5│    
│6╭╯         │6╭╯    
7╭╯          7╭╯     
 8            8      
Source

pub const fn inverted_annotations(self, invert: bool) -> Self

Set standard defaults for inverted drawing.

This writes the annotation before the vertex and reverses the annotation lines. This configuration option is commonly combined with an inverted character set and rendered with the lines in reverse order.

Note that setting this value will overwrite the values of the annotation_before_vertex and reverse_annotation_lines settings.

§Example

When inverted, the tree is transformed as follows. The third diagram uses an inverted character set and the lines are displayed last to first.

0             0              8
├┬╮           ├┬╮           7╰╮
│1├╮ L0   →   ││├╮ L1   ↺   │6╰╮
││││ L1       │1││ L0       ││5╰╮
││2│          ││2│          │││4│ L0
│3│├╮ L0      │3│├╮ L0      │││││ L1
│╭╯││     →   │╭╯││     ↺   │││││ L2
││╭┤│         ││╭┤│         ││╰┤│
│││4│ L0      │││││ L2      │╰╮││
│││╭╯ L1      │││││ L1      │3│├╯ L0
││││  L2  →   │││4│ L0  ↺   ││2│
││5│          ││5╭╯         │1││ L0
│6╭╯          │6╭╯          ││├╯ L1
7╭╯           7╭╯           ├┴╯
 8             8            0

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate 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 Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Config

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Config

Source§

impl Eq for Config

Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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

Source§

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

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.