1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::structure::{GValue, Vertex};

pub enum Either2<A: Into<GValue>, B: Into<GValue>> {
    A(A),
    B(B),
}

pub enum Either3<A: Into<GValue>, B: Into<GValue>, C: Into<GValue>> {
    A(A),
    B(B),
    C(C),
}

impl<A, B> From<Either2<A, B>> for GValue
where
    A: Into<GValue>,
    B: Into<GValue>,
{
    fn from(val: Either2<A, B>) -> Self {
        match val {
            Either2::A(a) => a.into(),
            Either2::B(b) => b.into(),
        }
    }
}

impl From<&str> for Either2<String, Vertex> {
    fn from(val: &str) -> Self {
        Either2::A(String::from(val))
    }
}

impl From<&Vertex> for Either2<String, Vertex> {
    fn from(val: &Vertex) -> Self {
        Either2::B(val.clone())
    }
}