I’m puzzled by a very simple operation I’d like to do. I have a struct which owns a
Vec. I want to consume that
Vec, and replace it with an empty
Vec. I could do this using its
drain method, but then I’d get an
Iterator, where I want an actual
Vec. True, I could
Iterator to get myself a
Vec again, but I doubt that would be an O(1) operation, in contrast to just copying the pointer, size and capacity information.
It seems like there must be an elegant solution to this problem, but I can’t think of it, or of how better to google for it. Any suggestions?