Expand description
Add prefix to each non-empty line.
use textwrap::indent;
assert_eq!(indent("
Foo
Bar
", " "), "
Foo
Bar
");
Empty lines (lines consisting only of whitespace) are not indented
and the whitespace is replaced by a single newline (\n
):
use textwrap::indent;
assert_eq!(indent("
Foo
Bar
\t
Baz
", "->"), "
->Foo
->Bar
->Baz
");
Leading and trailing whitespace on non-empty lines is kept unchanged:
use textwrap::indent;
assert_eq!(indent(" \t Foo ", "->"), "-> \t Foo \n");