Code Room
Code reviewHard
Question
Review this Rust inventory decrementer shared across worker threads via Arc<Mutex<...>>.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
fn reserve(stock: &Arc<Mutex<HashMap<u64, i32>>>, sku: u64, n: i32) -> bool { let available = { let map = stock.lock().unwrap(); *map.get(&sku).unwrap_or(&0) }; if available < n { return false; } let mut map = stock.lock().unwrap(); *map.entry(sku).or_insert(0) -= n; true}Run or narrate your approach, then ask the coach.