Function indent::indent_all_by

source ·
pub fn indent_all_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.

§Examples

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

For the version that doesn’t indent the first line, see indent_by.