pub struct Path { /* private fields */ }Expand description
Non-empty sequence of grid cells with an associated traversal cost.
Cost is hop-count (from_steps) or algorithm-supplied weighted cost
(from_steps_with_cost). Paths do not validate adjacency on construction;
callers use crate::Grid::path_is_walkable when geometry must be checked.
Implementations§
Source§impl Path
impl Path
Sourcepub fn from_steps(steps: Vec<Point>) -> Result<Self, PathBuildError>
pub fn from_steps(steps: Vec<Point>) -> Result<Self, PathBuildError>
Builds a path with cost equal to steps.len() - 1 (unit hop model).
§Errors
Returns PathBuildError::Empty when steps is empty.
Sourcepub fn from_steps_with_cost(
steps: Vec<Point>,
cost: usize,
) -> Result<Self, PathBuildError>
pub fn from_steps_with_cost( steps: Vec<Point>, cost: usize, ) -> Result<Self, PathBuildError>
Builds a path with an explicit traversal cost (weighted solvers).
§Errors
Returns PathBuildError::Empty when steps is empty.
Sourcepub fn cost(&self) -> usize
pub fn cost(&self) -> usize
Hop count (from_steps) or algorithm-supplied traversal cost (from_steps_with_cost).
Trait Implementations§
impl Eq for Path
Source§impl SearchPathCost for Path
impl SearchPathCost for Path
impl StructuralPartialEq for Path
Auto Trait Implementations§
impl Freeze for Path
impl RefUnwindSafe for Path
impl Send for Path
impl Sync for Path
impl Unpin for Path
impl UnsafeUnpin for Path
impl UnwindSafe for Path
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more