Re:Rust's Type System Is Turing-Complete: Type-Level Program...
by leshow on Friday March 10, 2017 @09:14PM
(#13843771)
How does that contradict what the post says? A trait object (the boxed fn in your example) is used for dynamic dispatch.
OP says "can also be used". It sure looks like the Fn trait is being used for dynamic dispatch in that example.
Hmm, I dunno about that. If you need to keep a collection of callbacks, that would most certainly be a collection of Fn/FnMut trait objects, that is this:
and not this: The same applies for any use of traits where the exact impl to be used is not known until runtime, like choosing a behavior from some set of behaviors in a configuration file.