0

I know async is new in rust, the Hyper example shows,

let make_svc = make_service_fn(|_conn| {
    async { Ok::<_, Infallible>(service_fn(hello)) }
});

But the docs show,

let make_svc = make_service_fn(|_conn| async {
    Ok::<_, Infallible>(service_fn(hello_world))
});

Is there a difference between these two constructs?

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468

1 Answers1

1

This is the same code, just formatted differently. As async closures do not yet exist in Rust, both examples use a closure that returns an async block. In example #1, the block is started in a new line inside the closure, while in example 2, the block starts in the same line as the closure's argument list.

justinas
  • 6,287
  • 3
  • 26
  • 36