-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add method for consuming a Vec and taking one element. #1512
Comments
You can do |
Aha! I didn't think of that. Although the fact that I didn't think of it is more evidence that this method could be useful. |
It's Rust... The first thing you should be thinking when you want something is: "can an |
The first thing I think is "does this type have a method that does this?" And if it doesn't it usually should. Also I don't see what |
I got confused with C++'s random access iterator |
Actually, |
Sometimes I want to take a single element from a
Vec
and throw the rest of theVec
away. I can do this usingswap_remove
then dropping theVec
(or letting it fall out of scope) but it would be clearer and slightly more efficient if there was a method for doing this directly.I propose adding this method to
Vec
:The text was updated successfully, but these errors were encountered: