pub fn indent(s: &str, prefix: &str) -> String
Expand description
Add prefix to each non-empty line.
use textwrap::indent;
assert_eq!(indent("
Foo
Bar
", " "), "
Foo
Bar
");
Lines consisting only of whitespace are kept unchanged:
use textwrap::indent;
assert_eq!(indent("
Foo
Bar
\t
Baz
", "->"), "
->Foo
->Bar
\t
->Baz
");
Leading and trailing whitespace on non-empty lines is kept unchanged:
use textwrap::indent;
assert_eq!(indent(" \t Foo ", "->"), "-> \t Foo ");