Move-After-Use Scenarios
Rust moves values on assignment, function call, and closure capture. Use references, Clone, or Copy types when you need multiple uses.
Search across all documentation pages
Rust moves values on assignment, function call, and closure capture. Use references, Clone, or Copy types when you need multiple uses.
error[E0382]: use of moved value: `v`
// Before
let v = vec![1, 2];
let w = v;
println!("{:?}", v); // error
// After: borrow
let v = vec![1, 2];
let w = &v;
println!("{:?}", v);
// After: clone
let v = vec![1, 2];
let w = v.clone();Fn consume:
fn take(s: String) {}
let name = String::from("Ada");
take(name);
// use name again -> error; clone before take if neededClosure move:
let data = vec![1];
let c = move || data.len(); // data moved into closureCopy types (integers, &T) duplicate instead of move. #[derive(Copy, Clone)] only when all fields Copy.
into_iter moves elements.| Alternative | Use When | Don't Use When |
|---|---|---|
&T arg | read-only reuse | callee needs ownership |
Rc | shared ownership | unique mutation without RefCell |
take() pattern | Option swap | always Some |
Field moved; access other fields ok if not partially moved struct in same binding pattern carefully.
FnOnce consumes captures; use Fn/FnMut for borrow.
for x in v moves; use for x in &v to borrow.
Binding by value moves; use ref in pattern ref x.
Label shows move site and use site.
Recreate owned value each iteration or use references.
Send moves value into channel.
Moving out of fn is intended; caller owns.
Swap placeholder while building state machine.
Small strings at boundary; not in inner loop without measure.
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.
Reviewed by Chris St. John·Last updated Jul 16, 2026