Move vs Copy Questions with Answers

10 practice questions on Move vs Copy (Rust) with answers and step-by-step solutions. Try 10 samples below, then practise all 10 free in the AptiNest app.

Sample questions

Question 1Easy

What is printed?

let x = 5;
let y = x;
println!("{} {}", x, y);
  1. Compile error: x moved
  2. 5 0
  3. 5 5
  4. Only 5 once

Answer: C. 5 5

Explanation

Integers implement Copy, so let y = x duplicates the value and x stays usable.

Step-by-step solution

  1. i32 is a Copy type.
  2. Assignment copies.
  3. Both print 5.

Why the other options are wrong

  • A. i32 is Copy, so x is still valid.
  • B. y receives a copy of 5, not 0.
  • D. Both placeholders print.

Question 2Easy

After let a: i32 = 5; let b = a; can a still be used?

  1. Yes; i32 is Copy, so b gets a copy
  2. Only after calling a.clone() to restore it
  3. Only if a is declared mut
  4. No; a was moved into b

Answer: A. Yes; i32 is Copy, so b gets a copy

Explanation

Integers implement Copy, so assignment duplicates the value.

Step-by-step solution

  1. I32 implements Copy because it is a plain integer.
  2. Let b = a copies the value, so a is still valid.
  3. So option A is the correct answer.

Why the other options are wrong

  • B. No clone is needed; the copy happens on assignment.
  • C. Mut is not needed to use a copy later.
  • D. I32 is Copy, so a was not moved into b.

Tip: Integers, booleans and chars are Copy, so they can be used again after assignment.

Question 3Easy

Which types are Copy, so assignment duplicates rather than moves?

  1. String and Vec<T>
  2. Simple scalars like i32, bool, char and f64
  3. Box<T>
  4. Every type, since Rust copies all values on assignment by default

Answer: B. Simple scalars like i32, bool, char and f64

Explanation

Copy types are cheap bitwise copies with no heap ownership; String and Vec own heap data.

Step-by-step solution

  1. Copy types are simple stack values.
  2. i32, bool, char, f64 are Copy.
  3. String, Vec, Box own heap data so they move.

Why the other options are wrong

  • A. They own heap data and move.
  • C. Box is not Copy.
  • D. Not all types are Copy.

Question 4Easy

Is &T (a shared reference) Copy?

  1. Only inside unsafe blocks, because references are raw pointers underneath
  2. Only for T = String
  3. Yes; copying a shared reference is fine
  4. No; references always move

Answer: C. Yes; copying a shared reference is fine

Explanation

Many shared references can coexist, so duplicating one is allowed. &mut T is not Copy.

Step-by-step solution

  1. A shared reference only lets you read the data.
  2. Many shared references can exist at once, so copying one is fine.
  3. So &T is Copy; option C is the correct answer.

Why the other options are wrong

  • A. A shared reference is not a raw pointer and needs no unsafe block to copy.
  • B. The rule covers every shared reference, not only String.
  • D. Shared references are copied, not moved.

Tip: Shared references are Copy; mutable references are not.

Question 5Easy

Which of these types is NOT Copy?

  1. i32
  2. bool
  3. (i32, char)
  4. Vec<i32>

Answer: D. Vec<i32>

Explanation

Vec owns heap memory, so it is moved, not copied. Primitives and tuples of them are Copy.

Step-by-step solution

  1. Copy types live fully on the stack.
  2. Vec owns a heap buffer.
  3. So it moves.

Why the other options are wrong

  • A. Plain integers are Copy.
  • B. bool is Copy.
  • C. A tuple of Copy types is Copy.

Question 6Medium

Copy vs Clone:

  1. Copy works for any type, while Clone only works for numbers and booleans
  2. Clone is implicit; Copy needs .copy()
  3. Copy is implicit and bitwise; Clone is explicit and may be expensive
  4. They are identical traits

Answer: C. Copy is implicit and bitwise; Clone is explicit and may be expensive

Explanation

Copy happens silently on assignment; Clone requires calling .clone() and can allocate.

Step-by-step solution

  1. Copy is implicit: assignment copies the value.
  2. Clone is explicit: you call .clone(), which can allocate.
  3. So option C is the correct answer.

Why the other options are wrong

  • A. Copy does not work for every type; all fields must be Copy.
  • B. Clone is explicit and Copy is implicit, the reverse of this.
  • D. Copy and Clone are different traits.

Tip: Use .clone() when you need a real duplicate of a value that is not Copy.

Question 7Medium

Can a type implement Copy if it contains a String field?

  1. No; all fields must be Copy
  2. Yes, as long as the struct is marked pub and derives Clone
  3. Yes, always
  4. Only if it also implements Drop

Answer: A. No; all fields must be Copy

Explanation

Copy requires every field to be Copy, and a type with Drop cannot be Copy.

Step-by-step solution

  1. Copy requires every field of the type to be Copy.
  2. String is not Copy because it owns heap memory.
  3. So a type with a String field cannot be Copy; option A is the correct answer.

Why the other options are wrong

  • B. Being pub and deriving Clone does not make a String field Copy.
  • C. A type with a String field cannot be Copy.
  • D. A type with Drop cannot be Copy, so implementing Drop does not allow it.

Tip: Copy works only when every field is Copy, such as numbers and booleans.

Question 8Medium

A tuple (i32, String) is assigned to another variable. What happens?

  1. It is a compile error to assign a tuple that contains a heap-allocated String
  2. The tuple moves, since String is not Copy
  3. Only the i32 moves
  4. It is copied, since tuples are always Copy

Answer: B. The tuple moves, since String is not Copy

Explanation

A tuple is Copy only if all elements are Copy.

Step-by-step solution

  1. A tuple is Copy only when all its elements are Copy.
  2. String is not Copy, so the tuple (i32, String) is not Copy.
  3. Assigning it moves the tuple, so option B is the correct answer.

Why the other options are wrong

  • A. Assignment is allowed; the tuple moves and nothing fails to compile.
  • C. The whole tuple moves, not only the i32.
  • D. The tuple is not Copy because of the String.

Tip: A tuple is Copy only if every element is Copy.

Question 9Medium

What does #[derive(Clone, Copy)] on a struct of two i32 fields allow?

  1. Sharing it across threads automatically
  2. Mutating it without mut
  3. Storing it on the heap without needing a Box or any other smart pointer
  4. Using the struct after assigning it to another variable

Answer: D. Using the struct after assigning it to another variable

Explanation

With Copy, assignment and passing by value copy the struct, so the original stays usable.

Step-by-step solution

  1. Copy makes assignment copy the struct instead of moving it.
  2. A struct of two i32 fields can be Copy.
  3. The original stays usable after assignment, so option D is the correct answer.

Why the other options are wrong

  • A. Copy does not make a type safe to share across threads.
  • B. Mut is still needed to change a value.
  • C. A Copy struct of plain fields lives on the stack; no Box is needed.

Tip: Derive Copy only for small plain types whose fields are all Copy.

Question 10Hard

Why is &mut T not Copy?

  1. It is too large to copy
  2. Mutable data cannot be copied
  3. Because mutable references are stored on the heap and need to be cloned
  4. Copying it would create two mutable references to the same data

Answer: D. Copying it would create two mutable references to the same data

Explanation

Rust guarantees at most one active mutable reference; copying would break that.

Step-by-step solution

  1. A mutable reference gives exclusive access to the data.
  2. Copying it would create a second mutable reference to the same data.
  3. So option D is the correct answer.

Why the other options are wrong

  • A. Size is not the reason; exclusivity is.
  • B. Mutable data can be moved; the problem is the second mutable reference.
  • C. Copying is not blocked by storage location; the exclusivity rule is the reason.

Tip: Only one mutable reference can be active at a time, so &mut T can never be Copy.

Practise all 10 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Rust topics · All topics