evenfurther / pathfinding

Pathfinding library for rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consistent function signatures

leesongun opened this issue · comments

In the current implementation, IDA* and IDDFS have different trait bounds and function signatures while IDDFS is a special case of IDA*. The following signature might be more general and useful in some cases, and it allows us to implement IDDFS as a special case of IDA*.

pub fn idastar_general<N, C, FN, IN, FH, FS, E>(
    start: &N,
    mut successors: FN,
    mut heuristic: FH,
    mut success: FS,
) -> Option<(Vec<E>, C)>
where
    N: Eq,
    C: Zero + Ord + Copy,
    FN: FnMut(&N) -> IN,
    IN: IntoIterator<Item = (E, C)>,
    FH: FnMut(&N) -> C,
    FS: FnMut(&N) -> bool,
    E://stands for edge, able to output arriving node

In my personal opinion, this does not necessarily have to be a breaking change, as existing functions can be implemented using the above.