E0205: Use after move
| Code | Category | Stability |
|---|---|---|
E0205 | Semantic | Permanent |
Explanation
Rue found a use of a move-type value after ownership of that value had already been transferred.
Likely cause
A struct or another non-Copy value was assigned, passed by value, or returned and then used again. Use the new owner, borrow the original when ownership need not transfer, or reinitialize the moved place before reusing it.
Examples
Use after ownership moves
struct Point { x: i32 }
fn main() -> i32 {
let point = Point { x: 42 };
let moved = point;
point.x
}
Use the new owner
struct Point { x: i32 }
fn main() -> i32 {
let point = Point { x: 42 };
let moved = point;
moved.x
}