-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Description
I'm wondering if it could be okay for Server to grow a lifetime parameter, reflecting the inner MakeServiceRef. I can't see why this is not allowed:
pub async fn run<'a, A>(addr: &'a SocketAddr, app: &'a A) -> Result<(), hyper::Error>
where
A: Application<RequestBody = Body, ResponseBody = Body> + Send + Sync,
{
Server::bind(addr)
.serve(make_service_fn(move |_| {
async {
Ok::<_, Infallible>(service_fn(move |req| {
let cx = Context::new(app, req);
A::handle(cx).map(Ok::<_, Infallible>)
}))
}
}))
.await
}errors with:
error: cannot infer an appropriate lifetime
--> mendes/src/lib.rs:37:51
|
37 | pub async fn run<'a, A>(addr: &'a SocketAddr, app: &'a A) -> Result<(), hyper::Error>
| ^^^ ...but this borrow...
...
42 | .serve(make_service_fn(move |_| {
| ----- this return type evaluates to the `'static` lifetime...
|
note: ...can't outlive the lifetime `'a` as defined on the function body at 37:22
--> mendes/src/lib.rs:37:22
|
37 | pub async fn run<'a, A>(addr: &'a SocketAddr, app: &'a A) -> Result<(), hyper::Error>
| ^^Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels