Eho*_*ret 2 rust verbatim-string
我正在寻找Rust中的逐字字符串(例如使用的C#@"This is a string and here ""I am between quotes without making a fuss""")。
有类似的东西吗?
这是令人惊讶的很难找到。
在rust中,原始字符串文字被包围r"",#如果需要使用引号,请添加。对于您的示例,
r#"This is a string and here "I am between quotes without making a fuss""#
应该工作。(双引号将在字符串中产生双引号。)
如果您需要带有#符号的内容,则可以执行以下操作
r###"This string can have ## in as many places as I like ##, but never three in a row ##"###
但是,在生锈的生弦中,不允许逸出。\n例如,您不能使用。但是,您可以包含所需的任何UTF-8字符。