This commit is contained in:
rsgltzyd 2024-11-23 00:03:28 +08:00
commit 21970c04d5
3 changed files with 31 additions and 0 deletions

7
string_test/Cargo.lock generated Normal file
View File

@ -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"

6
string_test/Cargo.toml Normal file
View File

@ -0,0 +1,6 @@
[package]
name = "string_test"
version = "0.1.0"
edition = "2021"
[dependencies]

18
string_test/src/main.rs Normal file
View File

@ -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, \"##\"")
}