1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::*;

pub trait KnowsRelativeAccessType<'a> {
    type RelativeType;
}

pub trait HasRelativeAccess<'a>: KnowsRelativeAccessType<'a> + KnowsPathSegment {
    fn relative<K>(self, path: impl IntoIterator<Item = K>) -> Option<Self::RelativeType>
    where K: Into<<Self as KnowsPathSegment>::PathSegment>;
}

impl<'a, T: KnowsRelativeAccessType<'a>> KnowsRelativeAccessType<'a> for &'a T {
    type RelativeType = T::RelativeType;
}