Code RoomBorrow panic on mutation
HardPrep Room Coding #1800

Borrow panic on mutation

Code reviewCode quality & reviewSenior–Staff~30 min

Review this Rust code that mutates a shared list via RefCell.

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.

0:00 of about 30 min
Mark a line and say what kind of problem it is.0 findings
1use std::cell::RefCell;
2use std::rc::Rc;
3 
4fn run() {
5 let list = Rc::new(RefCell::new(vec![1, 2, 3]));
6 let b = list.borrow();
7 let first = b[0];
8 list.borrow_mut().push(first + 10);
9 println!("{:?}", list.borrow());
10}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.