Mutable Borrow
Write a function called add_exclaim that takes a mutable borrow of a String and appends "!" to it. Call it twice on the same string, then print the result.
Expected output:
text
Wow!!
Hints:
- The function signature:
fn add_exclaim(text: &mut String) - Use
text.push_str("!")to append - The variable must be declared with
let mut - Pass it with
&mut my_string
rust
fn main() {
}