From fe8201df1e4b84085ce5a51137ce5d6cf9dd2a82 Mon Sep 17 00:00:00 2001 From: rsgl Date: Fri, 22 Nov 2024 21:40:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20string=5Ftest=20=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=8F=8A=E5=9F=BA=E6=9C=AC=E5=8A=9F=E8=83=BD=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- string_test/Cargo.lock | 7 +++++++ string_test/Cargo.toml | 6 ++++++ string_test/src/main.rs | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 string_test/Cargo.lock create mode 100644 string_test/Cargo.toml create mode 100644 string_test/src/main.rs diff --git a/string_test/Cargo.lock b/string_test/Cargo.lock new file mode 100644 index 0000000..55c4352 --- /dev/null +++ b/string_test/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "string_test" +version = "0.1.0" diff --git a/string_test/Cargo.toml b/string_test/Cargo.toml new file mode 100644 index 0000000..1b8e8b4 --- /dev/null +++ b/string_test/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "string_test" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/string_test/src/main.rs b/string_test/src/main.rs new file mode 100644 index 0000000..bd2fe2f --- /dev/null +++ b/string_test/src/main.rs @@ -0,0 +1,18 @@ +/* 填空并修复所有错误 */ +fn main() { + let raw_str = "Escapes don't work here: \x3F \u{211D}"; + // 修改上面的行让代码工作 + assert_eq!(raw_str, "Escapes don't work here: ? ℝ"); + + // 如果你希望在字符串中使用双引号,可以使用以下形式 + let quotes = r#"And then I said: "There is no escape!""#; + println!("{}", quotes); + + // 如果希望在字符串中使用 # 号,可以如下使用: + let delimiter = r###"A string with "# in it. And even "##!"###; + println!("{}", delimiter); + + // 填空 + let long_delimiter = "Hello, \"##\""; + assert_eq!(long_delimiter, "Hello, \"##\"") +}