Trait textwrap::core::Fragment[][src]

pub trait Fragment: Debug {
    fn width(&self) -> usize;
fn whitespace_width(&self) -> usize;
fn penalty_width(&self) -> usize; }

A (text) fragment denotes the unit which we wrap into lines.

Fragments represent an abstract word plus the whitespace following the word. In case the word falls at the end of the line, the whitespace is dropped and a so-called penalty is inserted instead (typically "-" if the word was hyphenated).

For wrapping purposes, the precise content of the word, the whitespace, and the penalty is irrelevant. All we need to know is the displayed width of each part, which this trait provides.

Required methods

fn width(&self) -> usize[src]

Displayed width of word represented by this fragment.

fn whitespace_width(&self) -> usize[src]

Displayed width of the whitespace that must follow the word when the word is not at the end of a line.

fn penalty_width(&self) -> usize[src]

Displayed width of the penalty that must be inserted if the word falls at the end of a line.

Loading content...


impl Fragment for Word<'_>[src]

Loading content...