代码之家  ›  专栏  ›  技术社区  ›  Natalie Perret

像生锈的一字不差的字符串?[副本]

  •  2
  • Natalie Perret  · 技术社区  · 7 年前

    @"This is a string and here ""I am between quotes without making a fuss""" ).

    2 回复  |  直到 7 年前
        1
  •  7
  •   Zarenor    7 年前

    This

    在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字符。

        2
  •  3
  •   Ömer Erden Eugen Dück    7 年前

    我猜 raw string literals 你在找什么?

     let raw_string_literal = r#" line1 \n still line 1"#;
     println!("{}", raw_string_literal);
    
    推荐文章