Traits for function items
Rust Internals [Unofficial]
July 2, 2026
hi @steffahn, do you remember if, at that time (when you wrote a ZeroSizedFunction in playground for Implementing traits on function pointers - #2 by steffahn - help - The Rust Programming Language Forum) the last line of
let v = 42;
// not a nice error message, but the following (if uncommented) doesn’t compile
let a = (move || println!("{:?}", v)).as_fn();
was refused at compile time, or at runtime? With current stable (v. 1.96.1) it's refused at runtime only! Maybe rustc got lazy.
Discussion in the ATmosphere