News for hackers. Stuff that matters.
Re:My favorite Rust function by dkersten on Saturday October 12, 2019 @08:04PM (#21237242)
unique_ptr disposes of the object its holding when it goes out of scope unless passed to another unique_ptr or ownership is explicitly released. Presumably klipt would std::move the unique_ptr, hence the universal reference (which seems unnecessary, just pass it by value).

Am I missing something? Does it not work with std::move?

Re:My favorite Rust function by Rusky on Saturday October 12, 2019 @08:07PM (#21237264)
Yes, you're missing that the type `T&&` is a reference, not a value, and so does not run the object's destructor when it goes out of scope.
Re:My favorite Rust function by dkersten on Saturday October 12, 2019 @08:24PM (#21237336)
Sorry, I edited right after hitting reply to clarify that I'm assuming the intention was to std::move the unique_ptr in, since it was T&& and not T&. Would that still not work?
Re:My favorite Rust function by Rusky on Saturday October 12, 2019 @08:35PM (#21237381)
It would still not work. All std::move does is cast to T&&, enabling overload resolution to pick a function with T&& as its parameter type.
Re:My favorite Rust function by dkersten on Sunday October 13, 2019 @12:36AM (#21238385)
Thanks for explaining!