Closed alatiera closed 6 years ago
bors r+
Hope you don't mind that I renamed the method! I think the into_*
convention is a little more common for methods that consume self
No not at all, I actually could not think of anything better at the time. Thanks for fixing it!
bors r+
bors r+
This allows to consume the
Channel
and get the owned vector/slice ofItems
. This can avoid the reallocation/clone of the whole Items slice in situations where you need to pass the ownership of the data, like when using futures.For example the compiler rightfully complains when trying to do the following:
Since you can only get a reference to an
Item
the compiler can't guarantee that it will satisfy the'static
lifetime requirement.A way to get the above example to compile is make the signature of
fn bar
the following:But that only moves the ownership problem in a higher part of the code, since you can never guarantee that
channel
will live until theFuture
is resolved.