fn main(){ println!("Welcome to the rust string literal tutorial!"); println!("A regular string has a \" on each side"); println!("A \" or a \\ in a string are escaped with a \\"); println!("This can lead to a mess with lots of \\\\\\\" being escaped but not \\\\\\\\\"") println("Here are some examples:"); let examples = vec!["\"Hello, world!\"", "\"This is a string with a \\\" in it\"", "\"This is a string with a \\\\ in it\""]; for (i, example) in examples.iter().enumerate(){ println!("example {}: {}", i+1, example); } println!("A raw string starts with a r###\" and can have any number of #s after the r"); println!("A raw string can contain any character, including newlines and is ended only by a \"### with the same number of #s as the opening r"); println!("Here are some examples:"); let examples = vec![r##"r#"Hello, world!"#"##, r###"r##"This is a string with a " and even a r#" in it"##"###, r##" r#" ##### any amount of hashtags can apear inside r"# as long as they don't close with a " "##]; for (i, example) in examples.iter().enumerate(){ println!("example {}: {}", i+1, example); } let example1 = r####" Lots of weird stuff can be done like having a ###" in the string we hope these different ways to escape strings are usefull to you Selecting the write one for the job is key to avoiding a mess of escape charecters like \"####; println!("{}", example1); println!("So make sure to choose between \"Hello\" and r##\"World\"## wisely!"); }