solomon_gremlin/structure/
either.rs

1use crate::structure::{GValue, Vertex, T};
2
3pub enum Either2<A: Into<GValue>, B: Into<GValue>> {
4	A(A),
5	B(B),
6}
7
8pub enum Either3<A: Into<GValue>, B: Into<GValue>, C: Into<GValue>> {
9	A(A),
10	B(B),
11	C(C),
12}
13
14impl<A, B> From<Either2<A, B>> for GValue
15where
16	A: Into<GValue>,
17	B: Into<GValue>,
18{
19	fn from(val: Either2<A, B>) -> Self {
20		match val {
21			Either2::A(a) => a.into(),
22			Either2::B(b) => b.into(),
23		}
24	}
25}
26
27impl From<&str> for Either2<String, T> {
28	fn from(val: &str) -> Self {
29		Either2::A(String::from(val))
30	}
31}
32
33impl From<T> for Either2<String, T> {
34	fn from(val: T) -> Self {
35		Either2::B(val)
36	}
37}
38
39impl From<&str> for Either2<String, Vertex> {
40	fn from(val: &str) -> Self {
41		Either2::A(String::from(val))
42	}
43}
44
45impl From<&Vertex> for Either2<String, Vertex> {
46	fn from(val: &Vertex) -> Self {
47		Either2::B(val.clone())
48	}
49}