Well, no, that second one isn't valid rust, perhaps you mean:
move || async move {}
But this is not equivalent to:
|| async move {}
crucially the closure is not going to take ownership of anything. This is kind of besides the point though, what I'm getting at is that both of the above are a closure which returns a future. i.e. you can also write them in this style:
|| {
return async move {};
}
Maybe that's more clear with the explicit return?
I don't understand your second question about it begin "inferred", I never used that word. make_service_fn is a convenience function for implementing the Service trait.
Ohhh.... I think I get it. The root of my confusion is that BRACES ARE OPTIONAL in Rust closures.
This is apparently valid Rust:
let func = || println!("foo!");
I didn't know that, which is why I thought "|| async move ..." was some weird form of pseudo-async-closure instead of what it is: a function that returns an async function.
Most of the code I see always uses braces in closures for clarity, but I now see that a lot of async code does not.
> I didn't know that, which is why I thought "|| async move ..." was some weird form of pseudo-async-closure instead of what it is: a function that returns an async function.
It does not return an async function, it is a closure that returns a future. Carefully read the function signature I had posted:
I don't understand your second question about it begin "inferred", I never used that word. make_service_fn is a convenience function for implementing the Service trait.