External Publication
Visit Post

Traits for function items

Rust Internals [Unofficial] July 2, 2026
Source

alice:

convenience holes

Same convenience holes experienced here.

Suggest Implementing traits on function pointers - #2 by steffahn - help - The Rust Programming Language Forum ---> " A possible workaround, using unsafe code, could be to check for a zero-sized and Copy type that implements Fn. Playing around in a playground got me something like this. This could be used to implement your trait. It seems difficult to also still support function pointers without specialization" -- thanks to @steffahn. I did not digest it fully yet, but it does allow to implement a trait/receiver function on a function item type.

Discussion in the ATmosphere

Loading comments...