String vs &str in Rust

What Is the Difference?

String owns mutable heap text while &str is an immutable borrowed reference to text.

Use String when you need to own and modify text, and &str when you only need to read a borrowed slice of text. String lives on the heap and is mutable, while &str is a reference to a string literal or part of a String that lives on the stack or elsewhere.

fn main() {
    let owned = String::from("hello");
    let borrowed: &str = "world";
    println!("{owned}, {borrowed}");
}