pub struct Group<T> { /* private fields */ }Expand description
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,
);Implementations§
Trait Implementations§
impl<T: Copy> Copy for Group<T>
Auto Trait Implementations§
impl<T> Freeze for Group<T>where
T: Freeze,
impl<T> RefUnwindSafe for Group<T>where
T: RefUnwindSafe,
impl<T> Send for Group<T>where
T: Send,
impl<T> Sync for Group<T>where
T: Sync,
impl<T> Unpin for Group<T>where
T: Unpin,
impl<T> UnwindSafe for Group<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more