Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Substring/Rust/substring.rust
Normal file
20
Task/Substring/Rust/substring.rust
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
let s = "abc文字化けdef";
|
||||
let n = 2;
|
||||
let m = 3;
|
||||
|
||||
// Print 3 characters starting at index 2 (c文字)
|
||||
println!("{}", s.chars().skip(n).take(m).collect::<String>());
|
||||
|
||||
// Print all characters starting at index 2 (c文字化けdef)
|
||||
println!("{}", s.chars().skip(n).collect::<String>());
|
||||
|
||||
// Print all characters except the last (abc文字化けde)
|
||||
println!("{}", s.chars().rev().skip(1).collect::<String>());
|
||||
|
||||
// Print 3 characters starting with 'b' (bc文)
|
||||
let cpos = s.find('b').unwrap();
|
||||
println!("{}", s[cpos..].chars().take(m).collect::<String>());
|
||||
|
||||
// Print 3 characters starting with "けd" (けde)
|
||||
let spos = s.find("けd").unwrap();
|
||||
println!("{}", s[spos..].chars().take(m).collect::<String>());
|
||||
Loading…
Add table
Add a link
Reference in a new issue