fn main() { let literal: &str = "hello"; // borrowed slice let mut owned: String = String::from(literal); // owned copy owned.push_str(", world"); owned.push('!'); println!("{}", owned); println!("literal is still usable: {}", literal); }
Click Run to execute this code.