[][src]Struct textwrap::core::Word

pub struct Word<'a> { /* fields omitted */ }

A piece of wrappable text, including any trailing whitespace.

A Word is an example of a Fragment, so it has a width, trailing whitespace, and potentially a penalty item.

Implementations

impl<'a> Word<'a>[src]

pub fn from(word: &str) -> Word<'_>[src]

Construct a new Word.

A trailing stretch of ' ' is automatically taken to be the whitespace part of the word.

pub fn break_apart<'b>(
    &'b self,
    line_width: usize
) -> impl Iterator<Item = Word<'a>> + 'b
[src]

Break this word into smaller words with a width of at most line_width. The whitespace and penalty from this Word is added to the last piece.

Examples

use textwrap::core::Word;
assert_eq!(
    Word::from("Hello!  ").break_apart(3).collect::<Vec<_>>(),
    vec![Word::from("Hel"), Word::from("lo!  ")]
);

Trait Implementations

impl<'a> Clone for Word<'a>[src]

impl<'a> Copy for Word<'a>[src]

impl<'a> Debug for Word<'a>[src]

impl Deref for Word<'_>[src]

type Target = str

The resulting type after dereferencing.

impl<'a> Eq for Word<'a>[src]

impl Fragment for Word<'_>[src]

impl<'a> PartialEq<Word<'a>> for Word<'a>[src]

impl<'a> StructuralEq for Word<'a>[src]

impl<'a> StructuralPartialEq for Word<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Word<'a>[src]

impl<'a> Send for Word<'a>[src]

impl<'a> Sync for Word<'a>[src]

impl<'a> Unpin for Word<'a>[src]

impl<'a> UnwindSafe for Word<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.