Refining Ch04.

This commit is contained in:
rust-lang.xfoss.com
2023-12-12 17:58:19 +08:00
parent 584cf03a38
commit 60bd1a1a61
2 changed files with 24 additions and 18 deletions

View File

@@ -1,11 +1,7 @@
fn main() {
let s = "नमस्ते";
let mut s = String::from("hello");
for c in s.chars() {
println!("{}", c);
}
s.push_str(", world!"); // push_str() 方法会追加一个字面值,到某个 String
for b in s.bytes() {
println!("{}", b);
}
println! ("{}", s); // 这将打印出 `hello, world!`
}