What is the idiomatic way to convert &str to String?

to_string just calls String::from, and String::from just calls to_owned. They're all inlined, so there's no performance cost to any of them. Format might be more expensive since it goes through all of the formatting abstractions.

11 Likes