Hacker News new | ask | show | jobs
by bnpxft 458 days ago
At the risk of making this another Go vs Rust comment, I hesitate to mention this, but Go developers copy structs all the time. We do it mostly as a way to make values immutable (and to avoid nil checking all the time). It is mostly not a problem. If something is a hot path, we'll use a pointer.

Whenever we pass by value as opposed to by address, Go makes a copy. Use .clone() in Rust, it is fine most of the time. Optimize it out if you find it is a performance bottleneck.

https://go.dev/play/p/Cm7mzRbva-5