docs: use local variable in closure (#1232)

The "Using closure captures for shared state" example creates two clones
when only one is needed.
This commit is contained in:
Mark Tuddenham 2022-08-09 15:23:16 +01:00 committed by GitHub
parent 95c6621db9
commit ad7c8c5cdb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -234,14 +234,14 @@
//! "/users",
//! post({
//! let shared_state = Arc::clone(&shared_state);
//! move |body| create_user(body, Arc::clone(&shared_state))
//! move |body| create_user(body, shared_state)
//! }),
//! )
//! .route(
//! "/users/:id",
//! get({
//! let shared_state = Arc::clone(&shared_state);
//! move |path| get_user(path, Arc::clone(&shared_state))
//! move |path| get_user(path, shared_state)
//! }),
//! );
//!