Cell<Client>,
}
...
fn server() -> Result<(), MainError> {
let state = &AppState::new()?;
actix_web::server::new(|| {
App::with_state(state)
});
std::cell::Cell<redis::Client> cannot be shared between threads safely
Both Cell<T> and RefCell<T> allows to do this in a single threaded way. However, neither Cell<T> nor RefCell<T> are thread safe (they do not implement Sync). If you need to do aliasing and mutation between multiple threads it is possible to use Mutex, RwLock or atomic types. https://doc.rust-lang.org/stable/std/cell/
Обсуждают сегодня