Expand description
§redent — strip redundant indentation and re-indent a string
Remove the common leading indentation from a multi-line string and then indent it by a
fixed amount. A faithful Rust port of the widely-used
redent npm package, built on
strip-indent and
indent-string.
use redent::{redent, redent_with};
// Just strip the common indent (count defaults to 0):
assert_eq!(redent(" foo\n bar"), "foo\n bar");
// Strip, then re-indent by two spaces:
assert_eq!(redent_with(" foo\n bar", 2, " ", false), " foo\n bar");#![no_std] (uses alloc).
Functions§
- redent
- Strip the common leading indentation from
string. - redent_
with - Strip the common leading indentation from
string, then indent every line withcountrepetitions ofindent.