It is not supported by the language with Rust 1.7, but Indoc is a procedural macro that does what you want. This means "indented document." It provides a macro called indoc!() , Which takes a multi-line string literal and discards it so that the left-most non-spatial character is in the first column.
let some_string = indoc!(" First line. Second line, with leading space.");
It also works for string literals.
let some_string = indoc!(r#" First line. Second line, with leading space."#);
The result in both cases is "First line\n Second line, with leading space."
source share