Stack-Only Data: Copy

Overview

Some stack-only types (such as integers) implement the Copy trait. Assigning them duplicates the value, so both variables remain valid after assignment.

Because no heap allocation ownership is transferred, this operation is cheap and does not trigger move semantics.

Official Rust Book: Stack-Only Data: Copy


Code example