Trait textwrap::wrap_algorithms::WrapAlgorithm[][src]

pub trait WrapAlgorithm: WrapAlgorithmClone + Debug {
    fn wrap<'a, 'b>(
        &self,
        words: &'b [Word<'a>],
        line_widths: &'b [usize]
    ) -> Vec<&'b [Word<'a>]>; }
Expand description

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

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

Implementors