Intermediate Rust
Q70 / 100

What is Rust's impl Trait syntax in function arguments?

Correct! Well done.

Incorrect.

The correct answer is B) Shorthand for a generic type parameter constrained by a trait: fn f(x: impl Display) is equivalent to fn f<T: Display>(x: T)

B

Correct Answer

Shorthand for a generic type parameter constrained by a trait: fn f(x: impl Display) is equivalent to fn f<T: Display>(x: T)

Explanation

fn double_and_print(x: impl Display + Debug) is cleaner than generics for simple cases. It's static dispatch — the compiler generates a concrete implementation.

Progress
70/100