Rust has a concept of a raw string to avoid any kind of escaping. This is similar to #166 (but not the same). It would be great if a standard non-raw representation of a string could be easily converted to/from the raw form. A raw string starts as r#", and only terminates when it sees "#. If original string literal contains "#, it should be wrapped with one more #: r##" ... "# ... "##
Describe alternatives you've considered
Lots of manual regex
fn main() {
let raw_str = r"Escapes don't work here: \x3F \u{211D}";
println!("{}", raw_str);
// If you need quotes in a raw string, add a pair of #s
let quotes = r#"And then I said: "There is no escape!""#;
println!("{}", quotes);
// If you need "# in your string, just use more #s in the delimiter.
// You can use up to 65535 #s.
let longer_delimiter = r###"A string with "# in it. And even "##!"###;
println!("{}", longer_delimiter);
}
Rust has a concept of a raw string to avoid any kind of escaping. This is similar to #166 (but not the same). It would be great if a standard non-raw representation of a string could be easily converted to/from the raw form. A raw string starts as
r#"
, and only terminates when it sees"#
. If original string literal contains"#
, it should be wrapped with one more#
:r##" ... "# ... "##
Describe alternatives you've considered Lots of manual regex
Additional context From the second example: