title: Trouble configuring Rust's Warp Filters
body: <p>I'm trying to setup a simple <code>GET</code> filter, but I'm having trouble getting it to compile.</p>
  
  <p>This is the function I'm trying to map to the request:</p>
  
  <pre><code>pub async fn get_users(reference_counter: Arc&lt;RwLock&lt;MysqlConnection&gt;&gt;) -&gt; Result&lt;impl Reply, Rejection&gt; {
     // Get users code here
  }
  </code></pre>
  
  <p>This is how I map the function to the <code>GET</code> request in <code>main.rs</code>:</p>
  
  <pre><code>#[tokio::main]
  async fn main() {
     let db_connection = storage::establish_connection();
     let lock = RwLock::new(db_connection);
     let reference_counter = Arc::new(lock);
     let ref_filter = warp::any().map(move || reference_counter.clone());
     let get_users = warp::get()
             .and(warp::path("users"))
             .and(ref_filter.clone())
             .and_then(user::get_users);
     warp::serve(get_users).run(([127, 0, 0, 1], 3030)).await;
  }
  </code></pre>
  
  <p>The compile error happens on <code>and_then</code>, it's pretty cryptic and this what it says:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0599]: no method named `and_then` found for struct `warp::filter::and::And&lt;warp::filter::and::And&lt;impl warp::filter::Filter+std::marker::Copy, warp::filters::path::Exact&lt;warp::filters::path::internal::Opaque&lt;&amp;str&gt;&gt;&gt;, warp::filter::map::Map&lt;impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:17:39: 17:72 reference_counter:_]&gt;&gt;` in the current scope
    --&gt; src\main.rs:21:14
     |
  21 |             .and_then(user::get_users);
     |              ^^^^^^^^ method not found in `warp::filter::and::And&lt;warp::filter::and::And&lt;impl warp::filter::Filter+std::marker::Copy, warp::filters::path::Exact&lt;warp::filters::path::internal::Opaque&lt;&amp;str&gt;&gt;&gt;, warp::filter::map::Map&lt;impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:17:39: 17:72 reference_counter:_]&gt;&gt;`
     |
    ::: C:\Users\Yasmani\.cargo\registry\src\github.com-1ecc6299db9ec823\warp-0.2.3\src\filter\and.rs:12:1
     |
  12 | pub struct And&lt;T, U&gt; {
     | --------------------
     | |
     | doesn't satisfy `_: warp::filter::FilterBase`
     | doesn't satisfy `_: warp::filter::Filter`
     |
     = note: the method `and_then` exists but the following trait bounds were not satisfied:
             `warp::filter::and::And&lt;warp::filter::and::And&lt;impl warp::filter::Filter+std::marker::Copy, warp::filters::path::Exact&lt;warp::filters::path::internal::Opaque&lt;&amp;str&gt;&gt;&gt;, warp::filter::map::Map&lt;impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:17:39: 17:72 reference_counter:_]&gt;&gt;: warp::filter::FilterBase`
             which is required by `warp::filter::and::And&lt;warp::filter::and::And&lt;impl warp::filter::Filter+std::marker::Copy, warp::filters::path::Exact&lt;warp::filters::path::internal::Opaque&lt;&amp;str&gt;&gt;&gt;, warp::filter::map::Map&lt;impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:17:39: 17:72 reference_counter:_]&gt;&gt;: warp::filter::Filter`
             `&amp;warp::filter::and::And&lt;warp::filter::and::And&lt;impl warp::filter::Filter+std::marker::Copy, warp::filters::path::Exact&lt;warp::filters::path::internal::Opaque&lt;&amp;str&gt;&gt;&gt;, warp::filter::map::Map&lt;impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:17:39: 17:72 reference_counter:_]&gt;&gt;: warp::filter::FilterBase`
             which is required by `&amp;warp::filter::and::And&lt;warp::filter::and::And&lt;impl warp::filter::Filter+std::marker::Copy, warp::filters::path::Exact&lt;warp::filters::path::internal::Opaque&lt;&amp;str&gt;&gt;&gt;, warp::filter::map::Map&lt;impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:17:39: 17:72 reference_counter:_]&gt;&gt;: warp::filter::Filter`
             `&amp;mut warp::filter::and::And&lt;warp::filter::and::And&lt;impl warp::filter::Filter+std::marker::Copy, warp::filters::path::Exact&lt;warp::filters::path::internal::Opaque&lt;&amp;str&gt;&gt;&gt;, warp::filter::map::Map&lt;impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:17:39: 17:72 reference_counter:_]&gt;&gt;: warp::filter::FilterBase`
             which is required by `&amp;mut warp::filter::and::And&lt;warp::filter::and::And&lt;impl warp::filter::Filter+std::marker::Copy, warp::filters::path::Exact&lt;warp::filters::path::internal::Opaque&lt;&amp;str&gt;&gt;&gt;, warp::filter::map::Map&lt;impl warp::filter::Filter+std::marker::Copy, [closure@src\main.rs:17:39: 17:72 reference_counter:_]&gt;&gt;: warp::filter::Filter`
  </code></pre>
  
  <p>I believe it has something to do with the type being returned by the closure in <code>ref_filter</code> not matching the type expected by the function <code>get_users</code>, but I'm not sure why. I believe the closure returns an <code>Arc&lt;RwLock&lt;MysqlConnection&gt;&gt;&gt;</code> and the <code>get_users</code> function takes the same. What is the problem?</p>