Intermediate Rust
Q53 / 100

What is the purpose of PhantomData<T>?

Correct! Well done.

Incorrect.

The correct answer is B) A zero-sized type used to make the type system aware of an unused generic parameter for lifetime or type variance purposes

B

Correct Answer

A zero-sized type used to make the type system aware of an unused generic parameter for lifetime or type variance purposes

Explanation

struct Iter<'a, T> { ptr: *const T, _phantom: PhantomData<&'a T> } tells the compiler the Iter borrows T with lifetime 'a, enabling proper variance.

Progress
53/100