Hacker News new | ask | show | jobs
by sockgrant 2217 days ago
1) he should pass by reference to avoid the extra copy. So in his example yes it’s dev naivety

2) but somewhere somehow this object will deallocate, so his trick of putting it to another thread would work if the deal location takes awhile. Same for cpp if you have a massive object in a unique ptr. So it’s not a rust issue

2 comments

Where's the extra copy? I don't see one. He's moving the struct into the function, getting size and then dropping it.
> avoid the extra copy

there is no copy happening here