Free function signatures

Hi everyone,

Been writing a small tree-like flattening iterator, which depends on function type. Its signature is:

pub struct TreeIter<T, Node, Iter, Func>
where
    Iter: Iterator<Item = Node>,
    Func: FnMut(Node) -> (Option<T>, Option<Iter>)
{
    root:   Option<Node>,
    layers: Vec<Iter>,
    func:   Func,
}

Then I tried to use this type to walk over directory tree. This is where I stuck.
First, abstract return types aren't here yet, so I cannot hide everything behind Iterator trait.
Second, I want to implement walk_dir via that TreeIter structure. In fact I need to return TreeIter with some unknown function as part of its signature:

fn walk_dir<T: AsRef<Path>>(root: T) -> itertree::TreeIter<fs::DirEntry, fs::DirEntry, fs::ReadDir, ???>

First I though about closure in place of ???. Though AFAIK closures cannot participate in type signatures this way. Then I thought about ordinary free function

fn read_dir(fs::DirEntry) -> (Option<fs::DirEntry>, Option<fs::ReadDir>)

But then I realized that I don't know how to specify free function signature.

So, how can this be solved? Or how do I at least specify type for any free, non-closure function?

Thanks

This might help: iterator - Figuring out return type of closure - Stack Overflow

Anyway if it's free function, fn(x)-> y should be enough.

Thanks a lot, this solved my problem.
Though I hope that ARTs will make in shortly.
Because using closures without them is a complete mess.