There was some confusion in #rust over when values are dropped. It was pointed out that the std::ops::Drop documentation only says drop is called if "a value goes out of scope", which is inaccurate:
- Scopes apply to variables, not values
- Values can be dropped for other reasons than scopes ending. For example, if a variable is re-assigned, the old value is dropped. There are also temporaries.
I don't know how to best phrase it, but focusing only on scopes is evidently a good way to confuse people.
There was some confusion in #rust over when values are dropped. It was pointed out that the
std::ops::Dropdocumentation only says drop is called if "a value goes out of scope", which is inaccurate:I don't know how to best phrase it, but focusing only on scopes is evidently a good way to confuse people.