Function textwrap::core::split_words[][src]

pub fn split_words<'a, I, S, Opt>(
    words: I,
    options: Opt
) -> impl Iterator<Item = Word<'a>> where
    I: IntoIterator<Item = Word<'a>>,
    S: WordSplitter,
    Opt: Into<Options<'a, S>>, 

Split words into smaller words according to the split points given by options.

Note that we split all words, regardless of their length. This is to more cleanly separate the business of splitting (including automatic hyphenation) from the business of word wrapping.


use textwrap::core::{split_words, Word};
use textwrap::{NoHyphenation, Options};

// The default splitter is HyphenSplitter:
let options = Options::new(80);
    split_words(vec![Word::from("foo-bar")], &options).collect::<Vec<_>>(),
    vec![Word::from("foo-"), Word::from("bar")]

// The NoHyphenation splitter ignores the '-':
let options = Options::new(80).splitter(NoHyphenation);
    split_words(vec![Word::from("foo-bar")], &options).collect::<Vec<_>>(),