Skip to main content

wrap

Function wrap 

Source
pub fn wrap(text: &str, max: u16) -> Vec<String>
Expand description

Splits text into lines no wider than max cells.

Explicit newlines are kept, words move to the next line whole when they fit on it (with the punctuation attached to them, so a comma never starts a line), and words longer than a line are broken between grapheme clusters; the punctuation closing such a word breaks off with the character before it, so . or ) never starts a line alone either. Spaces at a break are dropped.