[][src]Struct hierarchical_pathfinding::prelude::AbstractPath

pub struct AbstractPath<N: Neighborhood> { /* fields omitted */ }

A Path that may not be fully calculated yet.

This struct represents a Path that was generated by the PathCache. Since config.cache_paths may be set to false, there might by segments of this Path that are not yet calculated. In those cases, since the cost function is required to resolve those sections, it is necessary to call safe_next() or resolve(). Otherwise it is possible to treat this as an Iterator.

Warning: Calling next() on an AbstractPath with unknown segments will panic as soon as those segments are reached.

Warning: Keeping an AbstractPath after changing the Grid, or using a different cost function, leads to undefined behavior and panics.

You have been warned

Implementations

impl<N: Neighborhood> AbstractPath<N>[src]

pub fn cost(&self) -> Cost[src]

Returns the total cost of this Path. This value is always known and requires no further calculations.

pub fn length(&self) -> usize[src]

Returns the total length of this Path. This value is always known and requires no further calculations.

pub fn safe_next(
    &mut self,
    get_cost: impl FnMut(Point) -> isize
) -> Option<Point>
[src]

A variant of Iterator::next() that can resolve unknown segments of the Path. Use this method instead of next() when config.cache_paths is set to false.

pub fn resolve(self, get_cost: impl FnMut(Point) -> isize) -> Path<Point>[src]

Resolves all unknown sections of the Path.

if config.cache_paths is set to true, then calling this method is similar to calling path.collect::<Vec<Point>>().

The return value is a Path from the generics module, which is essentially a Vec, but with a cost member, since this path is consumed by resolve

Trait Implementations

impl<N: Clone + Neighborhood> Clone for AbstractPath<N>[src]

impl<N: Debug + Neighborhood> Debug for AbstractPath<N>[src]

impl<N: Neighborhood> Iterator for AbstractPath<N>[src]

type Item = Point

The type of the elements being iterated over.

fn next(&mut self) -> Option<Point>[src]

See Iterator::next

Panics

Panics if a segment of the Path is not known because config.cache_paths is set to false. Use safe_next in those cases.

Auto Trait Implementations

impl<N> RefUnwindSafe for AbstractPath<N> where
    N: RefUnwindSafe

impl<N> Send for AbstractPath<N> where
    N: Send

impl<N> Sync for AbstractPath<N> where
    N: Sync

impl<N> Unpin for AbstractPath<N> where
    N: Unpin

impl<N> UnwindSafe for AbstractPath<N> where
    N: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.