String Ownership and Move

Overview

String owns heap data, so assigning or passing it by value moves ownership unless you explicitly borrow or clone.

Understanding this move behavior explains why some bindings become invalid after transfer and why Rust prevents later use.

Official Rust Book: Variables and Data Interacting with Move


Code example