What is the difference between &str and String::new()?

When to use &str instead of String::new and vice versa ?

Thank you.

Have you read chapter 4 of the book? It goes into this question in detail Understanding Ownership - The Rust Programming Language

4 Likes