pub fn move_in_direction(
    start: (usize, usize),
    direction: (isize, isize),
    dimensions: (usize, usize)
) -> Option<(usize, usize)>
Expand description

Move a two-dimensional coordinate into a given direction provided that:

  • The start point is valid (given the dimensions).
  • The direction is not (0,0)
  • The target point is valid (given the dimensions).

§Example

use pathfinding::utils::move_in_direction;

let board = (8, 8);
assert_eq!(move_in_direction((5, 5), (-1, -2), board), Some((4, 3)));
assert_eq!(move_in_direction((1, 1), (-1, -2), board), None);