update at 2020-06-16 18:18:40 by ehlxr

This commit is contained in:
ehlxr
2020-06-16 18:18:40 +08:00
parent 4c9a6dec3c
commit 939f409503

View File

@@ -951,15 +951,18 @@ fn main() {
// println!("{} {} {}", s1, s3, s2); // println!("{} {} {}", s1, s3, s2);
println!("{} {}", s3, s2); println!("{} {}", s3, s2);
for c in "नमˑे".chars() { let hello = "测试中文字符串";
println!("{}", c); for c in hello.chars() {
print!("{} ", c);
} }
for b in "नमˑे".bytes() { println!("");
println!("{}", b); for b in hello.bytes() {
print!("{} ", b);
} }
let hello = "Здравствуйте"; println!("");
let s = &hello[0..4]; // let s = hello[1]; // Rust 的字符串不支持索引
println!("&hello[0..4]={}", s); // let s = &hello[0..4]; // thread 'main' panicked at 'byte index 4 is not a char boundary; it is inside '试' (bytes 3..6) of `测试中文字符串`', src/libcore/str/mod.rs:2219:5
print!("{}", &hello[0..3]);
} }
fn test_tuple(t: (i32, &str)) { fn test_tuple(t: (i32, &str)) {