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

pub trait Fragment: Debug {
    pub fn width(&self) -> usize;
pub fn whitespace_width(&self) -> usize;
pub 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

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

Displayed width of word represented by this fragment.

pub 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.

pub 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...

Implementors

impl Fragment for Word<'_>[src]

Loading content...