Hacker News new | ask | show | jobs
by unexaminedlife 2446 days ago
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.

2 comments

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.

Yes, to do anything interesting, you need to implement the Drop trait, which causes interesting behavior to happen here.
An example of the implementation is all that's missing from the blog post.