3 ms·
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 p
by unexaminedlife 7y 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.
- steveklabnik 7y agoYes, to do anything interesting, you need to implement the Drop trait, which causes interesting behavior to happen here.
- dmix 7y agoAn example of the implementation is all that's missing from the blog post.
- steveklabnik 7y agohttps://doc.rust-lang.org/stable/std/ops/trait.Drop.html https://doc.rust-lang.org/stable/std/ops/trait.Drop.html
- Rusky 7y agoThe 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.