Rellum Rellum

S0131: cannot borrow as mutable because value is already borrowed

Generated from rellum-diagnostics/src/db.rs.

Explanation

A mutable reference requires exclusive access to its referent. If a shared borrow is still live, creating &mut would allow mutation while another reader observes the same value.

Common causes

Canonical fixes

Before:

r = &buf
m = &mut buf
use_both(r, m)

After:

r = &buf
n = len(r)
m = &mut buf

Code example

r = &buf
m = &mut buf
use_both(r, m)