Struct pretty_trait::Seq [] [src]

pub struct Seq<T>(pub Vec<T>);

A wrapper that concatenates an arbitrary sequence of pretty-printable values.

Examples

Basic usage:

use pretty_trait::{JoinExt, Sep, Seq, to_string};

let max_line = Some(10);
let tab_size = 4;

let expected = "\
lorem
ipsum
dolor
sit
amet";

assert_eq!(
    to_string(
        &Seq(vec![
            "lorem".join(Some(Sep(1))),
            "ipsum".join(Some(Sep(1))),
            "dolor".join(Some(Sep(1))),
            "sit".join(Some(Sep(1))),
            "amet".join(None),
        ]),
        max_line,
        tab_size,
    ),
    expected
);

Note

Because a Seq is just a thin wrapper around a Vec, all of its items must be of the same type. When working with combinators like join this can sometimes be confusing. For example, the following code will not compile because the final element of the Vec does not have the same type as the others:

This example deliberately fails to compile
Seq(vec![
    "lorem".join(Sep(1)),
    "ipsum".join(Sep(1)),
    "dolor".join(Sep(1)),
    "sit".join(Sep(1)),
    "amet",
]);

Trait Implementations

impl<T: Clone> Clone for Seq<T>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for Seq<T>
[src]

[src]

Formats the value using the given formatter. Read more

impl<T: Pretty> Pretty for Seq<T>
[src]

[src]

Calculate the intrinsic size of this value, if it were to be displayed on a single line.

[src]

Render this value in a given context.

Auto Trait Implementations

impl<T> Send for Seq<T> where
    T: Send

impl<T> Sync for Seq<T> where
    T: Sync