| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
I prefer this version, I'm not sure what others' thoughts are though.
Sorry, something went wrong.
|
@youknowone could you explain a bit what your motivation is for this specific change? Reading this blog post, it looks like there is no difference in the two methods. |
Sorry, something went wrong.
|
There is a reddit link in the post you linked and I think this is my reason: https://www.reddit.com/r/rust/comments/4l71qw/how_do_i_convert_a_str_to_string_the_beginning_in/d3l23vf/ Derived pros: For most of this call, we just want to create String from &str. But, because .to_string() is defined to Display trait, we accidently can put a ToString object instead of &str object - which is not mostly intended. For to_owned(), if any object not a &str called with this method, it mostly will not return String. Which means no mistake. Probably .into() and String::from() can be a better choice for this reason. I think every other option except for to_string() is better then that. This is a kind of human engineering. Here is another PR I made with similar motivation. #1654 |
Sorry, something went wrong.
|
@youknowone thank you for your detailed explanation! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
please reject this PR if it is out of our preference or rust community convention.