to_owned should be used in favor of to_string - #29
Conversation
leaexplores
commented
Oct 4, 2015
ping? @SSheldon |
SSheldon
commented
Oct 5, 2015
Hey @ddrmanxbxfr, this looks fine but I'm curious if Since Do you think this code is more idiomatic with |
SSheldon
commented
Oct 17, 2015
Ping @ddrmanxbxfr! I could use your help here figuring out what's the best way to convert to a String :) |
leaexplores
commented
Oct 18, 2015
Hi @SSheldon my bad I was PTO for a few days. to_string does feel more indiomatic and semantically correct. However as of right now to_string does come with a runtime overhead and to_owned should be used in this case. Here's an example issue : rust-lang/rust#18404 Rust clippy (a rust linter) also checks to use to_owned in favor of to_string : https://github.com/Manishearth/rust-clippy/wiki#str_to_string May we see a merge between to_owned and to_string when to_string will be up par the performance level of to_owned. |
SSheldon
commented
Oct 25, 2015
Oh I didn't realize rust-clippy had a lint for this, that's a pretty strong point in favor of |
Hi, this PR stumbles upon a small nit I covered while seeking some code in cocoa-rs and servo.
It fixes the to_string calls for to_owned. It is much lighter in resources.
To_string as uses the whole formatting machinery just to clone a string.
Thanks for looking into it !