benashford / rs-es

A Rust client for the ElasticSearch REST API
Apache License 2.0
217 stars 44 forks source link

remove too strict lifetime binding #123

Closed antoine-de closed 5 years ago

antoine-de commented 5 years ago

the lifetime in SearchQueryOperation were binding external lifetime to self, and this was making non trivial use of the SearchQueryOperation very difficult. as you can see in a minimal setup https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=ca2db06f73dbcebdfbd7049232b727ad

this was leading to multiple mutable borrow if we want to keep a reference on the search_query.

fixed version: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=1068374f1f46d4c81265d1720984cbcd

Note: I had the problem when trying to set an optional timeout, as you can see here, the workaround was a bit ugly.

thanks @TeXitoi for the huge help in understanding the problem!

TeXitoi commented 5 years ago

The fixed link is not fixed. Here is the fixed link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=1068374f1f46d4c81265d1720984cbcd

antoine-de commented 5 years ago

yep sorry, due to github erratic behavior, the rust playground links do not always works for me :grimacing:

benashford commented 5 years ago

Good spot, thanks 👍

benashford commented 5 years ago

Released as part of 0.10.5