guppy/petgraph_support/
edge_ref.rs

1// Copyright (c) The cargo-guppy Contributors
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4use petgraph::{
5    graph::{EdgeReference, IndexType},
6    prelude::*,
7    visit::ReversedEdgeReference,
8};
9
10/// Provides a way to obtain graph::EdgeReference instances from arbitrary EdgeRef ones.
11pub trait GraphEdgeRef<'a, E, Ix: IndexType>: EdgeRef {
12    fn into_edge_reference(self) -> EdgeReference<'a, E, Ix>;
13}
14
15impl<'a, E, Ix: IndexType> GraphEdgeRef<'a, E, Ix> for EdgeReference<'a, E, Ix> {
16    fn into_edge_reference(self) -> EdgeReference<'a, E, Ix> {
17        self
18    }
19}
20
21impl<'a, E, Ix: IndexType> GraphEdgeRef<'a, E, Ix>
22    for ReversedEdgeReference<EdgeReference<'a, E, Ix>>
23{
24    fn into_edge_reference(self) -> EdgeReference<'a, E, Ix> {
25        self.into_unreversed()
26    }
27}