I defined, generically, 3 kind of call-execution methods, one using only Fn closure ( having the marker Fn ), second using FnMut closure and the third using only FnOnce closure. I used the same name in the tree call-execution methods, "execution". The current Rust compiler passed all of them without a single warning sign.
So which one the current Rust compiler will infer from these 3 calls at run time?
When my code has all the closures, Fn*, and when "execute" used a self-defined function as argument, Rust system at run time used:
-) The execution function defined by FnOnce, ( I expected actually the one defined by Fn.)
I kept only Fn and FnMut in the code ( I removed any thing related to FnOnce ) , when "execute" used a self-defined function as argument, Rust system at run time used in this case:
You can think of the Fn types as a hierarchy: FnOnce is the most restrictive, then FnMut, then Fn. So all Fns are FnMut and FnOnce, and all FnMuts are also FnOnce.
Given that a fn is like a Fn with an empty environment, all fns are Fns, and hence FnMut and FnOnce as well.
Could you share the actual code here? We don't have overloading, so you shouldn't have been able to define all three of these without changing the names as well.