-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drain() doc of vector is unclear #73844
Comments
"partially consumed" means taking a few elements out and then dropping the Is there any way to make this more clear in the docs? |
What leaked mean for you ? How would I leak drain struct ? Drop it ? |
No, leaking means specifically destroying a value without running its destructor, for example via |
So I think write:
Because in the current form the two note look like they apply both whereas it's two difference case, leaked or not. (I'm not sure leak is the good word here for me leak mean leak memory not forget it, so maybe say "without run it's destructor" is more clear) |
I myself am familiar with this usage of "to leak", but I don't know how I picked up that, why this is called leaking, or where it's explained in the docs. I suspect that this usage originates from smart pointers, for which destroying them without running destructors would leak the referenced objects. If we generalize this to something that is not a smart pointer, it's called jargon. Although it's convenient to use (in fact, there are more than ten instances of this usage in the standard library), it's not something we can expect to be understood for sure. For this reason, I agree with @Stargateur. Replacing the word with something like “destroyed without running its destructor” or at least adding a reference to |
@rustbot claim |
I wanted to move out a number of front element from a vector, like
my_vec.drain(..x)
but I wonder if this is the right way to do this cause doc is unclear, note 1 and note 2 say the opposite each other:https://doc.rust-lang.org/std/vec/struct.Vec.html#method.drain
This issue has been assigned to @poliorcetics via this comment.
The text was updated successfully, but these errors were encountered: