L3-37
L3-37 copied to clipboard
New Pool::connection() function in futures-03 branch borrows &Pool
It appears that the future returned from Pool::connection in the futures-03 branch borrows &self, whereas in the master branch it does not. This means that in order to spawn the future onto some executor where it needs to be 'static, the pool must be wrapped in an Arc (as a workaround). This is different to on the master branch where this extra step was not required. I believe that this is because async fn returns a future which borrows all of the arguments to the function, where as the version manually returning a future did not. This could perhaps be fixed with inline async blocks. I'm just putting this issue here to let you know about the change.
I managed to make it valid for 'static using an inline async block and use of clone(). It clones twice, regardless of whether it needs to wait for a free connection (maybe this can be adjusted - perhaps with Box::pin?). I have made sure that it compiles and works correctly without having to wrap it in Arc, and I have successfully run cargo test on the l337 crate (but haven't tried it in practice with one of the adapters). If you could take a look and evaluate whether you would want it to be merged, that would be fantastic :) https://github.com/Restioson/L3-37/commit/aa440138eaf7306c3d0eef97144159fc59cd414e