Usage of FnMut in `astar`
felix91gr opened this issue · comments
Hi @samueltardieu, long time no see ^^
I hope the global situation is treating you as well as it can. ❤️
I was taking a peek at the docs once again, and the fact that FnMut
is used in astar
grabbed my attention. Why is it that successors
, heuristic
and success
have to be FnMut
? Couldn't they be just Fn
?
Thanks in advance :)
Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.
Hi @felix91gr !
They are FnMut
because you might want to keep a state. For example, you might want to limit the search to a given number of steps, in which case you would make such a test in successors
or success
. You might also want to tweak heuristic
in order to influence the search less and less as it advances if it has not proven to be successful so far.
I hope this answers your question.
@samueltardieu I see, that makes a lot of sense!
And well, since Fn : FnMut
, I guess if one wanted to limit the input functions to be read-only, there is the option to do so, with a wrapper function over astar
that received Fn
types instead of FnMut
. That's actually super nice :)
Thank you, and take care 🙂