Rust has a ton of ways you can convert a &str to a String: .into(), .to_string(), .to_owned().
I'm never sure which one reads best. Maybe .to_owned() shows your intention the most clearly?
When I wrote my first Rust program, I got the advice "just clone everything until v1 compiles". I think this OK advice, but I think a better rule of thumb is "used owned types as much as possible".
I spent a ton of time returning &str or &[T] and fighting the borrow checker.
Is there a good mnemonic for remembering borrowed : owned types in Rust?
&str : String
&[u8] : Vec<u8>
These are easy because I see them often. Knowing the owned equivalent of Path (it's PathBuf) is harder.
I refactored some Rust string splitting logic:
old: &[&str] -> Vec<String>
new: &[&str] -> Vec<&str>
It's a little faster, but it's an interesting type signature. You can figure out more of how the new one works! It must be slicing into the input string.