Function textwrap::wrap [−][src]
Expand description
Wrap a line of text at width
characters. Strings are wrapped
based on their displayed width, not their size in bytes.
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 a Wrapper
and call its wrap
method.
The result is a vector of strings. Use wrap_iter
if you need an
iterator version.
Examples
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."]);