1//! A trait for types that have a root.
23use crate::KnowsVisitor;
45/// A trait for types that have a root.
6pub trait HasRoot: KnowsVisitor {
7/// Gets the root of the object.
8fn root(&self) -> Self::Visitor;
9}
1011/// A trait for types that have a root mutably.
12/// By design, accessing a Visitor parent is unsafe.
13pub unsafe trait HasRootMut: KnowsVisitor {
14/// Gets the root of the object.
15unsafe fn root_mut(&mut self) -> Self::VisitorMut;
16}
1718impl<T> HasRoot for Box<T>
19where T: HasRoot
20{
21fn root(&self) -> Self::Visitor {
22self.as_ref().root()
23 }
24}
2526unsafe impl<T> HasRootMut for Box<T>
27where T: HasRootMut
28{
29unsafe fn root_mut(&mut self) -> Self::VisitorMut {
30self.as_mut().root_mut()
31 }
32}