dylint

unnecessary_borrow_mut

What it does

Checks for calls to RefCell::borrow_mut that could be calls to RefCell::borrow.

Why is this bad?

A call to RefCell::borrow_mut “panics if the value is currently borrowed.” Thus, a call to RefCell::borrow_mut can panic in situations where a call to RefCell::borrow would not.

Example

x = *cell.borrow_mut();

Use instead:

x = *cell.borrow();