...
#[derive(Clone)]
struct Store {
questions: Arc<RwLock<HashMap<QuestionId, Question>>>,
answers: Arc<RwLock<HashMap<AnswerId, Answer>>>,
}
impl Store {
fn new() -> Self {
Store {
questions: Arc::new(RwLock::new(Self::init())),
answers: Arc::new(RwLock::new(HashMap::new())),
}
}
fn init() -> HashMap<String, Question> {
let file = include_str!("../questions.json");
serde_json::from_str(file).expect("can't read questions.json")
}
}
...
async fn add_answer(
store: Store,