#Conditional move closure error.
23 messages · Page 1 of 1 (latest)
If you're getting large or confusing errors please post the full error message from cargo check in a code block instead of the errors in your IDE so that we can understand your problem better:
```rust
// error from cargo check here
```
sure
you want to put #[cfg(not(feature = "ssl"))] in front of the server.bind line
since you would bind the server twice if the ssl feature was activated
I see
I guess my fix wasn't actually correct even if that wasn't what you wanted to do
yeah
the problem lies here:
#[cfg(not(feature = "listenfd"))]
-normal_bind()?.run().await?;
+let server = normal_bind()?.run().await?;
since you want to use the server later on again
wait no
I can't read rn
can you send the code around line 92?
oh now I see
(at least I hope so)
you will want to remove the normal_bind closure and instead duplicate its code (could be using a macro)
I removed that part since it doesn't actually help with that exact deduplication here
though yes, cfg-if would still be very useful
what's the problem with that?
you could have a function ```rs
let normal_bind = |server: HttpServer| {
move || -> Result<_, anyhow::Error> {
todo!("use server")
}
};
//...
normal_bind(server)();
but you don't need to specify anything with a closure
the argument could probably be deduced by the compiler, you could also specify HttpServer<_, _, _, _> if it doesn't