Intermediate
Rust
Q52 / 100
What is the newtype pattern?
Correct! Well done.
Incorrect.
The correct answer is A) Using a tuple struct of one field to create a distinct named type for type safety
A
Correct Answer
Using a tuple struct of one field to create a distinct named type for type safety
Explanation
struct Meters(f64); and struct Kilograms(f64) are distinct types despite holding f64. Prevents accidental mixing of units while having zero runtime cost.
Progress
52/100