plexus/graph/view/convert.rs
1pub trait IntoKeyedSource<T>: Sized {
2 fn into_keyed_source(self) -> T;
3}
4
5pub trait FromKeyedSource<T>: Sized {
6 fn from_keyed_source(source: T) -> Option<Self>;
7}
8
9pub trait IntoView<T>: Sized {
10 fn into_view(self) -> Option<T>;
11}
12
13impl<T, U> IntoView<U> for T
14where
15 T: Sized,
16 U: FromKeyedSource<T>,
17{
18 fn into_view(self) -> Option<U> {
19 U::from_keyed_source(self)
20 }
21}