S0134: cannot move borrowed value
Generated from rellum-diagnostics/src/db.rs.
Explanation
A value cannot be moved while a reference to it is still live. Moving would invalidate the reference and could leave later reference uses dangling.
Common causes
- passing a value to an owning function while an & reference is still used later
- returning or storing an owner while a mutable borrow is active
- moving a graph value in the same region where it is borrowed
Canonical fixes
- finish using the reference before moving the value
Before:
r = &buf
x = consume(buf)
len(r)
After:
r = &buf
n = len(r)
x = consume(buf)
- change the consuming API to accept a reference if it only reads the value
Code example
r = &buf
x = consume(buf)
len(r)