gdsl 0.2.1

GDSL is a graph data-structure library including graph containers, connected node strutures and efficient algorithms on those structures. Nodes are independent of a graph container and can be used as connected smart pointers.
Documentation
use super::*;

pub type Filter<'a, K, N, E> = &'a mut dyn FnMut(&Edge<K, N, E>) -> bool;
pub type ForEach<'a, K, N, E> = &'a mut dyn FnMut(&Edge<K, N, E>);

pub enum Method<'a, K, N, E>
where
    K: Clone + Hash + Display + PartialEq + Eq,
    N: Clone,
    E: Clone,
{
    Empty,
    Filter(Filter<'a, K, N, E>),
    ForEach(ForEach<'a, K, N, E>),
}

impl<'a, K, N, E> Method<'a, K, N, E>
where
    K: Clone + Hash + Display + PartialEq + Eq,
    N: Clone,
    E: Clone,
{
    pub fn exec(&mut self, e: &Edge<K, N, E>) -> bool {
        match self {
            Method::Empty => true,
            Method::Filter(f) => f(e),
            Method::ForEach(f) => {
                f(e);
                true
            }
        }
    }
}