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


#1

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

Thank you.


#2

Have you read chapter 4 of the book? It goes into this question in detail https://doc.rust-lang.org/book/second-edition/ch04-00-understanding-ownership.html