Function textwrap::wrap
[−]
[src]
pub fn wrap(s: &str, width: usize) -> Vec<String>
Wrap a line of text at width
characters. Strings are wrapped
based on their displayed width, not their size in bytes.
use textwrap::wrap; assert_eq!(wrap("Concurrency without data races.", 15), vec!["Concurrency", "without data", "races."]); assert_eq!(wrap("Concurrency without data races.", 20), vec!["Concurrency without", "data races."]);
This function creates a Wrapper on the fly with default settings.
If you need to set a language corpus for automatic hyphenation, or
need to wrap many strings, then it is suggested to create Wrapper
and call its wrap
method.