Skip to main content

Walk

Struct Walk 

Source
pub struct Walk<'a, N> { /* private fields */ }
Expand description

A walk standing on a set of nodes of one type.

Each hop is a whole frontier at a time, and the frontier is a set, so a diamond in the graph does not turn into two copies of the node at the far end. See Graph::walk.

Implementations§

Source§

impl<'a, N: Node> Walk<'a, N>

Source

pub fn out<E: Edge<From = N>>(self) -> Result<Walk<'a, E::To>>

Follow every edge of this kind forwards.

E::From is N, which is what makes a hop the graph does not have a compile error rather than an empty answer.

§Errors

Code::Invalid if called from inside a callback holding this database.

Source

pub fn incoming<E: Edge<To = N>>(self) -> Result<Walk<'a, E::From>>

Follow every edge of this kind backwards.

§Errors

Code::Invalid if called from inside a callback holding this database.

Source

pub fn filter(self, keep: impl FnMut(&N) -> bool) -> Result<Walk<'a, N>>

Keep only the nodes that pass.

The node is read to be looked at, so this is the expensive filter and it belongs at the end of a walk rather than in the middle of one.

§Errors

Code::Corrupt if a node on the walk is not an N.

Source

pub fn len(&self) -> usize

How many nodes the walk is standing on.

Source

pub fn is_empty(&self) -> bool

Whether the walk reached nothing.

Source

pub fn ids(self) -> Vec<Id<N>>

The nodes the walk reached, as handles.

Source

pub fn nodes(self) -> Result<Vec<N>>

The nodes the walk reached, read out.

A probe per node, which is what 11 section 4 prices this at and the reason it is a separate call rather than what a hop hands back.

§Errors

Code::Corrupt if a node on the walk is not an N.

Trait Implementations§

Source§

impl<N: Node> Debug for Walk<'_, N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, N> !RefUnwindSafe for Walk<'a, N>

§

impl<'a, N> !Send for Walk<'a, N>

§

impl<'a, N> !Sync for Walk<'a, N>

§

impl<'a, N> !UnwindSafe for Walk<'a, N>

§

impl<'a, N> Freeze for Walk<'a, N>
where PhantomData<fn() -> N>: Freeze,

§

impl<'a, N> Unpin for Walk<'a, N>
where PhantomData<fn() -> N>: Unpin,

§

impl<'a, N> UnsafeUnpin for Walk<'a, N>
where PhantomData<fn() -> N>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.