[−][src]Trait textwrap::wrap_algorithms::WrapAlgorithm
Describes how to wrap words into lines.
The simplest approach is to wrap words one word at a time. This is
implemented by FirstFit
. If the smawk
Cargo feature is
enabled, a more complex algorithm is available, implemented by
OptimalFit
, which will look at an entire paragraph at a time
in order to find optimal line breaks.
Required methods
fn wrap<'a, 'b>(
&self,
words: &'b [Word<'a>],
line_widths: &'b [usize]
) -> Vec<&'b [Word<'a>]>
&self,
words: &'b [Word<'a>],
line_widths: &'b [usize]
) -> Vec<&'b [Word<'a>]>
Wrap words according to line widths.
The line_widths
slice gives the target line width for each
line (the last slice element is repeated as necessary). This
can be used to implement hanging indentation.
Please see the implementors of the trait for examples.
Implementations on Foreign Types
impl WrapAlgorithm for Box<dyn WrapAlgorithm>
[src]
fn wrap<'a, 'b>(
&self,
words: &'b [Word<'a>],
line_widths: &'b [usize]
) -> Vec<&'b [Word<'a>]>
[src]
&self,
words: &'b [Word<'a>],
line_widths: &'b [usize]
) -> Vec<&'b [Word<'a>]>
Implementors
impl WrapAlgorithm for FirstFit
[src]
fn wrap<'a, 'b>(
&self,
words: &'b [Word<'a>],
line_widths: &'b [usize]
) -> Vec<&'b [Word<'a>]>
[src]
&self,
words: &'b [Word<'a>],
line_widths: &'b [usize]
) -> Vec<&'b [Word<'a>]>