4 ms·
You can also... just allow a copy to occur. My friend is always talking my ear off about how people are so afraid to copy a string in Rust, going through insane
by ironmagma 5y ago
You can also... just allow a copy to occur. My friend is always talking my ear off about how people are so afraid to copy a string in Rust, going through insane motions to avoid it, when there is some actual quadratic complexity somewhere else that's actually eating up time, whereas a single string copy is undoubtedly taking mere nanoseconds.
- ben-schaaf 5y agoMy guess would be that it's people (like myself) being burnt by C++'s copy semantics, where you have to deliberately and consciously avoid making copies everywhere.
- ironmagma 5y agoYou have to do that in Rust too. But only if you really want to avoid a copy. Who needs to avoid copying strings? Chances are that is not the slow part of your program.
- seoaeu 5y agoI think it is the opposite in Rust. You have to specifically write `.clone()` which makes people feel like they're doing something wrong, when actually it is just a fast and harmless function call