Do note as well, that making your closures take the other as a parameter would be perfectly viable using a custom-Fn because that would allow us to refer to self where self is the closure.

Also

Please note that closures, specifically ones that capture variables, either by reference or value, are objects, that need to be instantiated. Closures that do not capture or regular functions are simply functions, they are places in memory where instructions are kept, not objects, and a fn() -> () is a function pointer, which only points to a function, and doesn’t contain an object or attached data.

Regarding an example with closures, this, as @OptimisticPeach said, won’t be possible in general, due to it requiring two “objects” that refer to each other, thus implying self-referentiability which, as we know, is a problematic pattern in Rust.

However, this can be avoided by using static closures (it requires naming the type of a closure, which in stable can only be done with environment-less closures by coercing them to fn() pointers), since a static is not part of a closure’s environment:

Lastly, and this one is the most interesting, is that since a closure is just an object with a method, we can avoid the self-referentiability issue by having one “object” with two methods (we lose some sugar but it remains fine).

(In my example, is_even and is_odd will be sharing a reference to an out_stream: