If got something like:
async fn handle_connection()
{
let incoming = async move
{
// do some work
};
let outgoing = async move
{
// do some work
};
select!
{
_ = incoming.fuse() => {}
_ = outgoing.fuse() => {}
};
}
The idea is that both run concurrently and that the function ends when either one ends, dropping all data related to the other future.
Select here complains that those futures aren't Unpin. I suppose I'll end up using pin_utils
to pin them on the stack (to avoid boxing).
However, I don't understand why they aren't Unpin. I don't really see how they could move, since they will be dropped before the stack frame of this function gets popped.
Note that handle_connection
is being used with Box::pin
, so generator of this function will be pinned.