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
use crate::*;

impl<'a, Value> KnowsGetType<'a> for RootVisitor<Value>
where Value: KnowsGetType<'a>,
      Value::GetType: KnowsVisitor<'a>
{
    type GetType = <Value::GetType as KnowsVisitor<'a>>::Visitor;
}

impl<'a, Value> HasGet<'a> for &'a RootVisitor<Value>
where Value: Clone + HasGet<'a>,
      Value::GetType: KnowsPathSegment + KnowsVisitor<'a>,
      <Value::GetType as KnowsVisitor<'a>>::Visitor: KnowsPathSegment<PathSegment = <Value::GetType as KnowsPathSegment>::PathSegment>,
      Self::GetType: HasVisitorConstructor<'a, Value = Value::GetType>,
      RootVisitor<Value>: Into<<Self::GetType as KnowsParent<'a>>::Parent> + Clone,
{
    fn get<PathSegment>(self, segment: PathSegment) -> Option<Self::GetType>
    where PathSegment: Into<<Self::GetType as KnowsPathSegment>::PathSegment> {
        self
            .value
            .clone()
            .get(segment)
            .map(|value| self.visit(value))
    }
}