@@ -76,10 +76,10 @@ impl<T> Node<T> {
7676#[ derive( Debug ) ]
7777pub struct NodeRef < ' a , T : ' a > {
7878 /// Node ID.
79- pub id : NodeId ,
79+ id : NodeId ,
8080
8181 /// Tree containing the node.
82- pub tree : & ' a Tree < T > ,
82+ tree : & ' a Tree < T > ,
8383
8484 node : & ' a Node < T > ,
8585}
@@ -88,10 +88,10 @@ pub struct NodeRef<'a, T: 'a> {
8888#[ derive( Debug ) ]
8989pub struct NodeMut < ' a , T : ' a > {
9090 /// Node ID.
91- pub id : NodeId ,
91+ id : NodeId ,
9292
9393 /// Tree containing the node.
94- pub tree : & ' a mut Tree < T > ,
94+ tree : & ' a mut Tree < T > ,
9595}
9696
9797// Trait implementations regardless of T.
@@ -171,6 +171,16 @@ impl<T> Tree<T> {
171171}
172172
173173impl < ' a , T : ' a > NodeRef < ' a , T > {
174+ /// Returns the ID of this node.
175+ pub fn id ( & self ) -> NodeId {
176+ self . id
177+ }
178+
179+ /// Returns the tree owning this node.
180+ pub fn tree ( & self ) -> & ' a Tree < T > {
181+ self . tree
182+ }
183+
174184 /// Returns the value of this node.
175185 pub fn value ( & self ) -> & ' a T {
176186 & self . node . value
@@ -213,6 +223,16 @@ impl<'a, T: 'a> NodeRef<'a, T> {
213223}
214224
215225impl < ' a , T : ' a > NodeMut < ' a , T > {
226+ /// Returns the ID of this node.
227+ pub fn id ( & self ) -> NodeId {
228+ self . id
229+ }
230+
231+ /// Returns the tree owning this node.
232+ pub fn tree ( & mut self ) -> & mut Tree < T > {
233+ self . tree
234+ }
235+
216236 fn node ( & mut self ) -> & mut Node < T > {
217237 unsafe { self . tree . node_mut ( self . id ) }
218238 }
0 commit comments