Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRustZero-cost abstraction in codegenSingle-choice MCQ

`apply` is generic over the closure type `F`. Comparing this against a `Box<dyn Fn(i32) -> i32>` version, which statement about codegen is correct?

fn apply<F: Fn(i32) -> i32>(f: F, x: i32) -> i32 { f(x) } fn main() { let k = 10; let r = apply(|x| x + k, 5); println!("{}", r); }