Hello, I’m a bit confused by why we need both String and &str.
I understand that String is an owned string while &str represents a borrowed string.
I also read that I can pass &String to a function that wants an &str and it will get coerced but it’s not clear why they are different types. What’s the difference between the two?
Is str alone (without being a reference) used anywhere or is it something that’s only ever created and owned by the compiler?
Finally, if I write a function that takes a string reference, what should it’s type be? I feel that the answer it’s &str but I’m not entirely sure why