Skip to content

Correct Way to Achieve Query Pipelining with Vec of Futures #212

Answered by weiznich
ahmed-said-jax asked this question in Q&A
Discussion options

You must be logged in to vote

I wouldn't call this "workaround" but expected behavior. It's one of rusts core values that you cannot have more than one mutable reference at the same time. You have exactly that by using an async function there as the compiler generated future contains any function argument.

Also, I'd be happy to create a PR to update the documentation in the query pipelining section to illustrate how to do it with any number of futures rather than just two.

That would be great, especially if you can point out that requirement to return a future that does not borrow the connection (e.g. by using BoxFuture with a lifetime decoupled from the connection) explicitly.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ahmed-said-jax
Comment options

Answer selected by ahmed-said-jax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants