1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub trait KnowsRoot<'a> {
    type Root;
}

pub trait HasRoot<'a>: KnowsRoot<'a> {
    fn root(self) -> Self::Root;
}

impl<'a> KnowsRoot<'a> for &String {
    type Root = Self;
}

impl<'a> HasRoot<'a> for &String {
    fn root(self) -> Self::Root {
        self
    }
}