1
0
mirror of https://github.com/actix/actix-website synced 2025-01-22 16:15:56 +01:00

Fix examples

This commit is contained in:
Katherine Philip 2019-07-18 20:59:11 +07:00
parent 31630f61f8
commit 77b86e778f

View File

@ -1,5 +1,6 @@
// <setup>
use actix_web::{web, App, HttpServer};
use std::sync::{Mutex};
// This struct represents state
struct AppState {
@ -19,7 +20,7 @@ struct AppStateWithCounter {
}
fn _index(data: web::Data<AppStateWithCounter>) -> String {
let mut counter = state.counter.lock().unwrap(); // <- get counter's MutexGuard
let mut counter = data.counter.lock().unwrap(); // <- get counter's MutexGuard
*counter += 1; // <- access counter inside MutexGuard
format!("Request number: {}", counter) // <- response with count