rshyper_core/traits/
convert.rs

1/*
2    Appellation: indexable <module>
3    Contrib: @FL03
4*/
5use crate::{EdgeId, VertexId};
6
7/// a trait for converting a type into a valid [`EdgeId`]
8pub trait IntoEdgeId<Idx> {
9    fn into_edge_index(self) -> EdgeId<Idx>;
10}
11
12/// a trait for converting a type into a valid [`VertexId`]
13pub trait IntoNodeId<Idx> {
14    fn into_node_index(self) -> VertexId<Idx>;
15}
16
17/*
18 ************* Implementations *************
19*/
20impl<T> IntoNodeId<T> for T
21where
22    T: Into<VertexId<T>>,
23{
24    fn into_node_index(self) -> VertexId<T> {
25        self.into()
26    }
27}
28
29impl<T> IntoEdgeId<T> for T
30where
31    T: Into<EdgeId<T>>,
32{
33    fn into_edge_index(self) -> EdgeId<T> {
34        self.into()
35    }
36}