Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Rust's + implementation consumes the String on the left, so the default behavior doesn't do any allocation unless the string needs more capacity. This makes it impossible to "get it wrong" in the way you seem to be suspecting.

The part beginners tend to get wrong is trying to add a &str to a &str, which just doesn't have a + implementation to begin with, so they get lost.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: