I am reading the documentation on RefCell and Cell to better wrap my head around interior mutability and when to use it.
I came across this statement and I was wondering if anyone could help me unpack it a bit.
RefCell<T>uses Rust's lifetimes to implement 'dynamic borrowing', a process whereby one can claim temporary, exclusive, mutable access to the inner value. Borrows for
RefCell<T>s are tracked 'at runtime', unlike Rust's native reference types which are entirely tracked statically, at compile time. Because
RefCell<T>borrows are dynamic it is possible to attempt to borrow a value that is already mutably borrowed; when this happens it results in thread panic.
It seems to me that if this is only used in single threaded applications, what is the situation where a thread panic need to arise. In a single threaded application there should be no fear of data races, and no simultaneous borrows, so what is the situation that would cause a thread panic?