Slice and change string
fn main() { let mut text = String::from("Foobar"); println!("{}", text); let slice = &text[0..=2]; println!("{}", slice); text.clear(); text.push_str("qwerty"); println!("{}", text); //println!("{}", slice); }
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
fn main() { let mut text = String::from("Foobar"); println!("{}", text); let slice = &text[0..=2]; println!("{}", slice); text.clear(); text.push_str("qwerty"); println!("{}", text); //println!("{}", slice); }