Struct pretty_trait::Group [] [src]

pub struct Group<T> { /* fields omitted */ }

A wrapper which groups its contents so they will fit onto one line if possible, even if their environment has been broken across multiple lines.

Examples

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

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

let expected_ungrouped = "\
hello
,
world
!";

assert_eq!(
    to_string(
        &"hello"
            .join(Sep(0))
            .join(",")
            .join(Sep(1))
            .join("world")
            .join(Sep(0))
            .join("!"),
        max_line,
        tab_size,
    ),
    expected_ungrouped
);

let expected_grouped = "\
hello,
world!";

assert_eq!(
    to_string(
        &Group::new("hello".join(Sep(0)).join(","))
            .join(Sep(1))
            .join(Group::new("world".join(Sep(0)).join("!"))),
        max_line,
        tab_size,
    ),
    expected_grouped,
);

Methods

impl<T: Pretty> Group<T>
[src]

[src]

Trait Implementations

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

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T: Copy> Copy for Group<T>
[src]

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

[src]

Formats the value using the given formatter. Read more

impl<T: Pretty> Pretty for Group<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 Group<T> where
    T: Send

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