Updated 'src/common_collections/strings.md'.

This commit is contained in:
Hector PENG
2025-06-07 18:14:00 +08:00
parent 228baef40c
commit 426e1794e1
3 changed files with 505 additions and 103 deletions

View File

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