Warp error: error[E0277]: the trait bound `impl warp::Future: warp::filter::FilterBase` is not satisfied

780 views Asked by At

Warp is returning the error,

error[E0277]: the trait bound `impl warp::Future: warp::filter::FilterBase` is not satisfied
  --> src/http.rs:31:26
   |
31 |     let routes = index().or(users());
   |                             ^^^^^^^ the trait `warp::filter::FilterBase` is not implemented for `impl warp::Future`

I have essentially this,

pub async fn users() -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone {
  # stuff
}

What am I doing wrong?

1

There are 1 answers

5
Ibraheem Ahmed On

or takes a functions that returns a Filter. Your function is marked async, and returns a Future<Output = Filter>. You can instead use or_else, the async version of or:

let routes = index().or_else(users());