fera-graph 0.2.0

Graph data structures and algorithms.
Documentation
use prelude::*;

use std::iter::Empty;

pub struct Never<T>(!, T);

impl<'a, K: EdgeKind> VertexTypes<'a, Never<K>> for Never<K> {
    type VertexIter = Empty<()>;
    type OutNeighborIter = Empty<()>;
}

impl<K: EdgeKind> WithVertex for Never<K> {
    // TODO: replace with ! when https://github.com/rust-lang/rust/pull/51404 get merged
    type Vertex = ();
    type OptionVertex = Option<()>;
}

impl<'a, K: EdgeKind> EdgeTypes<'a, Never<K>> for Never<K> {
    type EdgeIter = Empty<()>;
    type OutEdgeIter = Empty<()>;
}

impl<K: EdgeKind> WithEdge for Never<K> {
    type Kind = K;
    type Edge = ();
    type OptionEdge = Option<()>;

    fn orientation(&self, _e: Edge<Self>) -> Orientation {
        self.0
    }

    fn source(&self, _e: Edge<Self>) -> Vertex<Self> {
        self.0
    }

    fn target(&self, _e: Edge<Self>) -> Vertex<Self> {
        self.0
    }
}

impl<K: EdgeKind> VertexList for Never<K> {
    fn vertices(&self) -> VertexIter<Self> {
        self.0
    }
}

impl<K: EdgeKind> EdgeList for Never<K> {
    fn edges(&self) -> EdgeIter<Self> {
        self.0
    }
}

impl<K: EdgeKind> Adjacency for Never<K> {
    fn out_neighbors(&self, _v: Vertex<Self>) -> OutNeighborIter<Self> {
        self.0
    }
}

impl<K: EdgeKind> Incidence for Never<K> {
    fn out_edges(&self, _v: Vertex<Self>) -> OutEdgeIter<Self> {
        self.0
    }
}