News for hackers. Stuff that matters.
Re:My favorite Rust function by unexaminedlife on Saturday October 12, 2019 @09:07PM (#21237535)
I get the feeling this doesn't really get into the meat of what "drop" is. It seems you can't really explain why you "love" a function without discussing its purpose. Maybe I'm wrong, I'm only really an outsider looking in when it comes to rust, but it does fascinate me as far as its goals. I would go so far as to say that it will be important for systems programmers to know in the not too distant future (if it's not already).

Isn't it really only there in case someone needs to "hook into" the drop functionality before the variable is dropped? Please correct me if I'm wrong.

EDIT: Minor editing to clarify meaning.

Re:My favorite Rust function by Rusky on Sunday October 13, 2019 @12:03AM (#21238282)
The post isn't talking about the drop method of the Drop trait, which is used to hook into the drop functionally.

It's talking instead about std::mem::drop, a standard library function that drops a value before it would ordinarily go out of scope.

Re:My favorite Rust function by steveklabnik on Saturday October 12, 2019 @09:21PM (#21237603)
Yes, to do anything interesting, you need to implement the Drop trait, which causes interesting behavior to happen here.
Re:My favorite Rust function by dmix on Saturday October 12, 2019 @09:40PM (#21237696)
An example of the implementation is all that's missing from the blog post.
Re:My favorite Rust function by steveklabnik on Saturday October 12, 2019 @10:00PM (#21237791)