Is it possible to write something like:
fn main() {
let my_string: &str = \"Testing for new lines \\
might work like this?\";
Another way to do this is to use a raw string literal:
Raw string literals do not process any escapes. They start with the character
U+0072
(r
), followed by zero or more of the characterU+0023
(#
) and aU+0022
(double-quote) character. The raw string body can contain any sequence of Unicode characters and is terminated only by anotherU+0022
(double-quote) character, followed by the same number ofU+0023
(#) characters that preceded the openingU+0022
(double-quote) character.All Unicode characters contained in the raw string body represent themselves, the characters
U+0022
(double-quote) (except when followed by at least as manyU+0023
(#
) characters as were used to start the raw string literal) orU+005C
(\
) do not have any special meaning.Examples for string literals:
"foo"; r"foo"; // foo "\"foo\""; r#""foo""#; // "foo" "foo #\"# bar"; r##"foo #"# bar"##; // foo #"# bar "\x52"; "R"; r"R"; // R "\\x52"; r"\x52"; // \x52