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]
fn clone(&self) -> Seq<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for Seq<T>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more