Move
Move semantics describe the transfer of a value or its resources to another binding or object rather than duplicating them.
Learn Rust in a Month of Lunches
Move semantics is the behavior in which transferring a non-Copy value transfers its ownership and prevents use of the original binding.
- How it is used
- Explains why passing a String prevents reuse of its binding and why a thread closure may need to take values by ownership.
- How deep it goes
- Walks through a failed function call and its compiler error, then applies move to closures without detailing memory-layout internals.
- Examples
- Uses a String passed twice to a function, an i32 passed twice, and a spawned closure that prints a String.
- What you can do after
- Diagnose/debug with compiler move errors, then choose borrowing, cloning, or a move closure when the example calls for it.
Refactoring to Rust
Move semantics is Rust's ownership-transfer behavior, under which a value becomes inaccessible through its original binding after transfer.
- How it is used
- Explains why passing owned values into functions makes the original bindings inaccessible.
- How deep it goes
- Explains ownership transfer, scope-based dropping, and lifetime graphs, without extending beyond these introductory examples.
- Examples
- Uses Artwork values, admire_art calls, compiler diagnostics, and lifetime graphs.
- What you can do after
- Diagnose use-of-moved-value errors by tracing ownership transfers and lifetime disappearance across function calls.
Rust in Action: Systems programming concepts and techniques
Move semantics define how transferring ownership of a value invalidates or relocates its previous binding instead of implicitly copying the value.
- How it is used
- Explains why Rust rejects later uses of values passed to functions, reassigned, returned, or captured by spawned closures.
- How deep it goes
- Traces assignment, arguments, returns, and closure captures with compiler errors and working listings, but defers deeper capture details.
- Examples
- Uses CubeSat status checks, a returned CubeSat, compiler diagnostics, and shared pause values in spawned threads.
- What you can do after
- Diagnose/debug with it by reading moved-value and closure-lifetime errors and choosing reassignment, return, Copy, or move.
Read how Rust in Action: Systems programming concepts and techniques explains move →
C++ Concurrency in Action, Second Edition
Move semantics are C++ language features that allow resources to be transferred from one object to another without copying them.
- How it is used
- Transfers std::thread ownership when returning, passing, or reorganizing threads.
- How deep it goes
- Explains explicit moves from named objects, implicit moves from temporaries, and termination when assignment overwrites a thread-owning destination.
- Examples
- Uses ownership transfers among three std::thread objects and shows returning or passing threads.
- What you can do after
- Apply it via std::move to transfer named std::thread ownership without assigning over an already-associated destination.
Read how C++ Concurrency in Action, Second Edition explains move →
Idiomatic Rust
Move semantics transfer ownership of a value into a new binding or operation rather than copying the value.
- How it is used
- Uses ownership transfer to pass values into functions or closures, return them, and avoid borrowing or cloning.
- How deep it goes
- Defines moves across calls, closures, assignment, and returns, then gives practical guidance for choosing value or reference passing.
- Examples
- Demonstrates reversing a String by value, returning multiple results in a tuple, and consuming a captured String in a closure.
- What you can do after
- Apply moves to transfer non-Copy values into functions or closures, return ownership, and judge when references are preferable.
Related concepts
- closureconfigures · A closure is a function or callable value together with access to bindings from the lexical environment in which it was created.
- ownershipuses · Ownership is a programming-language model that assigns responsibility for controlling a value or resource, including its lifetime and eventual cleanup.
- copy semanticscontrasts with · Copy semantics are the rules by which copying a value creates an independent representation while leaving the original usable.
- copycontrasts with · Copying is the creation of a separate representation of an existing value, object, or data, preserving some or all of its contents or state.
- big fiveused by · The rule of five is a C++ guideline that classes managing resources should consider defining a destructor, copy constructor, copy assignment operator, move constructor, and move assignment operator.
- referencealternative to · A reference is an indirect value or relationship that identifies or provides access to another value, object, resource, or source.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




