I am writing a tool that analysis code. I am currently trying to test all possible syntax that can store then call a function. There are a few syntax that I don't understand how I should write them.
I can't figure how I should write the version 9, 10, 11 and 14. And btw, did I forget other way to call a function (except directly calling it of course!)?
Every case where you have a -> dyn Fn() doesn’t make any sense. Unsized return types are not (yet) an option in Rust. For your problems with 9, 10, and 11, the problem is that you have a function like e.g. impl Fn() -> (impl Fn() -> impl Fn()) and call that one to get some impl Fn() -> impl Fn(). Put into a Box, this cannot convert to a dyn Fn() since it still has a non-() return type. You could call it "another time" to get some impl Fn() before putting it into the Box, like e.g.
My reaction was something like "pfffffffffffffffffffffffffff"! I should have used impl Fn() -> Fct and not impl Fn() -> GetFctTrait and the like. Thanks!
And thanks @2e71828 for the extra examples, I need to add them.
Here’s one last possibility from me. There’s a combinatorial explosion of these, though; at some point, you’ll need to rely on whatever system you’re using for type inference to tell you that something is callable.