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

Yes, but if you have a large value type it will be on the stack unless you manually box it. Passing by value can get quite expensive quite fast, especially if the value keeps being passed up and down the call chain.


Is this really true? What do you mean by value types? The types that implement copy or any struct types? Because I think struct types only get moved


Move and copy are both the same operation under the hood, move just means that the old version is marked invalid and not available for use anymore.

For large structs (or enums), move and copy both compile into memcpy. If the structures are large, this can take a lot of time.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: