我看到操作员r#""
Rust 了,但我找不到它的功能.它在创建JSON时派上了用场:
let var1 = "test1";
let json = r#"{"type": "type1", "type2": var1}"#;
println!("{}", json) // => {"type2": "type1", "type2": var1}
接线员r#""
叫什么名字?我该怎么做?
我看到操作员r#""
Rust 了,但我找不到它的功能.它在创建JSON时派上了用场:
let var1 = "test1";
let json = r#"{"type": "type1", "type2": var1}"#;
println!("{}", json) // => {"type2": "type1", "type2": var1}
接线员r#""
叫什么名字?我该怎么做?
我找不到它的作用
它与字符串文字和原始字符串有关.我认为它在this part of the documentation中得到了很好的解释,在发布的代码块中,你可以看到它的功能:
"foo"; r"foo"; // foo "\"foo\""; r#""foo""#; // "foo" "foo #\"# bar"; r##"foo #"# bar"##; // foo #"# bar "\x52"; "R"; r"R"; // R "\\x52"; r"\x52"; // \x52
它不需要转义字符串中的特殊字符.