Skip to main content

PrettyBuilder

Trait PrettyBuilder 

Source
pub trait PrettyBuilder<'a, T> {
    // Required methods
    fn flat_alt<E>(self, inline: E) -> PrettyTree<'a, T>
       where E: Into<PrettyTree<'a, T>>;
    fn indent(self, indent: usize) -> PrettyTree<'a, T>;
    fn nest(self, offset: isize) -> PrettyTree<'a, T>;
}
Expand description

The PrettyPrint trait is implemented by types that can be pretty-printed.

Required Methods§

Source

fn flat_alt<E>(self, inline: E) -> PrettyTree<'a, T>
where E: Into<PrettyTree<'a, T>>,

Acts as self when laid out on multiple lines and acts as that when laid out on a single line.

use pretty::{Arena, DocAllocator};

let arena = Arena::<()>::new();
let body = arena.line().append("x");
let doc = arena
    .text("let")
    .append(arena.line())
    .append("x")
    .group()
    .append(body.clone().flat_alt(arena.line().append("in").append(body)))
    .group();

assert_eq!(doc.1.pretty(100).to_string(), "let x in x");
assert_eq!(doc.1.pretty(8).to_string(), "let x\nx");
Source

fn indent(self, indent: usize) -> PrettyTree<'a, T>

Acts as self when laid out on a single line and acts as that when laid out on multiple lines.

Source

fn nest(self, offset: isize) -> PrettyTree<'a, T>

Increase the indentation level of this document.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a, T: Text<'a>> PrettyBuilder<'a, T> for PrettyTree<'a, T>

Source§

impl<'a, T: Text<'a>> PrettyBuilder<'a, T> for PrettySequence<'a, T>