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

master
ehlxr 2020-06-16 18:18:40 +08:00
parent 4c9a6dec3c
commit 939f409503
1 changed files with 33 additions and 30 deletions

View File

@ -951,15 +951,18 @@ fn main() {
// println!("{} {} {}", s1, s3, s2);
println!("{} {}", s3, s2);
for c in "नमˑे".chars() {
println!("{}", c);
let hello = "测试中文字符串";
for c in hello.chars() {
print!("{} ", c);
}
for b in "नमˑे".bytes() {
println!("{}", b);
println!("");
for b in hello.bytes() {
print!("{} ", b);
}
let hello = "Здравствуйте";
let s = &hello[0..4];
println!("&hello[0..4]={}", s);
println!("");
// let s = hello[1]; // Rust 的字符串不支持索引
// 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)) {