Outer A* caller uses try_into to relax type requirements.
use super::BaseMap;
use std::cmp::Ordering;
use std::collections::{BinaryHeap, HashMap};
+use std::convert::TryInto;
/// Bail out if the A* search exceeds this many steps.
const MAX_ASTAR_STEPS: usize = 65536;
/// Request an A-Star search. The start and end are specified as index numbers (compatible with your
/// BaseMap implementation), and it requires access to your map so as to call distance and exit determinations.
-pub fn a_star_search(start: usize, end: usize, map: &dyn BaseMap) -> NavigationPath {
- AStar::new(start, end).search(map)
+pub fn a_star_search<T>(start: T, end: T, map: &dyn BaseMap) -> NavigationPath
+where
+T: TryInto<usize>,
+{
+ AStar::new(start.try_into().ok().unwrap(), end.try_into().ok().unwrap()).search(map)
}
/// Holds the result of an A-Star navigation query.
