String::from(…) vs. ….to_owned() vs. ….to_string()
I started learning Rust from YouTube a few weeks ago, and I see that there's a difference between string literals, which are &str string slices, and actual Strings.
In the first tutorial series I watched, the guy in the videos used ….to_owned() to convert a string slice to a String. I also see some people using ….to_string() (which I have been using). I'm now watching Let's Get Rusty's series on the Rust book, and he always uses String::from(…).
Do these just all do the same thing, in the context of converting a string slice to a String? Which one should I use?
Oh and I've also seen that some people prefer ….into() when there's enough context. I also read briefly last night about the history of ….to_owned() and ….to_string() and about how ….to_string() has been fixed to match the performance of ….to_owned() (specialization for str::to_string())
I'd appreciate your thoughts on this.
Edit: Alright, so after reading everyone's comments I'm leaning towards String::from and to_owned. Personally I think String::from looks cooler, lol, so I'm gonna use that