I'm using actix-web
at the latest alpha 1.0.0
release. My main
looks like this:
fn main() {
let config = Config::new();
let config_clone = config.clone();
HttpServer::new(move || App::new().configure(configure(config_clone)))
.bind()
.unwrap()
.run();
}
My configure
function:
pub fn configure(_config: Config) -> impl Fn(&mut RouterConfig) {
move |mut _c| {
();
}
}
The goal is that I want all of my actual application configuration for actix-web
to live in one consolidated place, which is the goal of the App::configure
method.
I get the following error:
error[E0507]: cannot move out of captured variable in an `Fn` closure
--> src/main.rs:32:65
|
30 | let config_clone = config.clone();
| --------- captured outer variable
31 |
32 | HttpServer::new(|| App::new().configure(configure(config_clone)))
| ^^^^^^^^^ cannot move out of captured variable in an `Fn` closure
How can I pass my Config
value into the underlying closure? I need to do this because configuration will inform what happens inside of that closure.