To which scope is a function's returned value sent?

And to fix your code, you'll probably want to use a reference to borrow the variable from an upper scope:

fn string_uppercase(data: &mut String) {
    *data = data.to_uppercase();
    println!("{data}");
}

fn main() {
    let mut data = "Rust is great!".to_string();

    string_uppercase(&mut data);

    println!("{data}");
}

And now it successfully screams at me about how "RUST IS GREAT! RUST IS GREAT!"

Also see chapter 4 of the Book.

2 Likes