Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
|||
fn main() {
|
||||
let s = String::from("žluťoučký kůň");
|
||||
|
||||
let mut modified = s.clone();
|
||||
modified.remove(0);
|
||||
println!("{}", modified);
|
||||
|
||||
let mut modified = s.clone();
|
||||
modified.pop();
|
||||
println!("{}", modified);
|
||||
|
||||
let mut modified = s;
|
||||
modified.remove(0);
|
||||
modified.pop();
|
||||
println!("{}", modified);
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
fn main() {
|
||||
let s = "žluťoučký kůň";
|
||||
|
||||
println!(
|
||||
"{}",
|
||||
s.char_indices()
|
||||
.nth(1)
|
||||
.map(|(i, _)| &s[i..])
|
||||
.unwrap_or_default()
|
||||
);
|
||||
|
||||
println!(
|
||||
"{}",
|
||||
s.char_indices()
|
||||
.nth_back(0)
|
||||
.map(|(i, _)| &s[..i])
|
||||
.unwrap_or_default()
|
||||
);
|
||||
|
||||
println!(
|
||||
"{}",
|
||||
s.char_indices()
|
||||
.nth(1)
|
||||
.and_then(|(i, _)| s.char_indices().nth_back(0).map(|(j, _)| i..j))
|
||||
.map(|range| &s[range])
|
||||
.unwrap_or_default()
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue