Shared mutable state in Hyper
问题 I'm trying to create a counter in a Hyper web server that counts the number of requests it has received. I'm using a Arc<Mutex<u64>> to hold onto count. However, I haven't been able to figure out the right combination of move and .clone() to satisfy the types of the closures. Here's some code that compiles, but resets the counter on each request: extern crate hyper; use hyper::rt::Future; use hyper::service::service_fn_ok; use hyper::{Body, Response, Server}; use std::sync::{Arc, Mutex}; fn