indent_by

Function indent_by 

Source
pub fn indent_by<'a, S>(number_of_spaces: usize, input: S) -> String
where S: Into<Cow<'a, str>>,
Expand description

Indents every line that is not empty by the given number of spaces, starting from the second line.

The first line of the string is not indented so that it can be placed after an introduction sequence that has already begun the line.

ยงExamples

assert_eq!(format!("  items: {}", indent::indent_by(2, "[\n  foo,\n  bar,\n]\n")),
"  items: [
    foo,
    bar,
  ]
")

For the version that also indents the first line, see indent_all_by.