@@ -161,15 +161,16 @@ impl<'a, K, V> Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge
161161impl < K , V > Handle < NodeRef < marker:: Owned , K , V , marker:: Leaf > , marker:: Edge > {
162162 /// Moves the leaf edge handle to the next leaf edge and returns the key and value
163163 /// in between, while deallocating any node left behind.
164- /// Unsafe for three reasons:
164+ /// Unsafe for two reasons:
165165 /// - The caller must ensure that the leaf edge is not the last one in the tree
166166 /// and is not a handle previously resulting from counterpart `next_back_unchecked`.
167- /// - If the leaf edge is the last edge of a node, that node and possibly ancestors
167+ /// - Further use of the updated leaf edge handle is very dangerous. In particular,
168+ /// if the leaf edge is the last edge of a node, that node and possibly ancestors
168169 /// will be deallocated, while the reference to those nodes in the surviving ancestor
169- /// is left dangling; thus further use of the leaf edge handle is dangerous .
170- /// It is, however, safe to call this method again on the updated handle.
171- /// if the two preconditions above hold.
172- /// - Using the updated handle may well invalidate the returned references .
170+ /// is left dangling.
171+ /// The only safe way to proceed with the updated handle is to compare it, drop it,
172+ /// call this method again subject to both preconditions listed in the first point,
173+ /// or call counterpart `next_back_unchecked` subject to its preconditions .
173174 pub unsafe fn next_unchecked ( & mut self ) -> ( K , V ) {
174175 unsafe {
175176 replace ( self , |leaf_edge| {
@@ -183,15 +184,16 @@ impl<K, V> Handle<NodeRef<marker::Owned, K, V, marker::Leaf>, marker::Edge> {
183184
184185 /// Moves the leaf edge handle to the previous leaf edge and returns the key
185186 /// and value in between, while deallocating any node left behind.
186- /// Unsafe for three reasons:
187+ /// Unsafe for two reasons:
187188 /// - The caller must ensure that the leaf edge is not the first one in the tree
188189 /// and is not a handle previously resulting from counterpart `next_unchecked`.
189- /// - If the lead edge is the first edge of a node, that node and possibly ancestors
190+ /// - Further use of the updated leaf edge handle is very dangerous. In particular,
191+ /// if the leaf edge is the first edge of a node, that node and possibly ancestors
190192 /// will be deallocated, while the reference to those nodes in the surviving ancestor
191- /// is left dangling; thus further use of the leaf edge handle is dangerous .
192- /// It is, however, safe to call this method again on the updated handle.
193- /// if the two preconditions above hold.
194- /// - Using the updated handle may well invalidate the returned references .
193+ /// is left dangling.
194+ /// The only safe way to proceed with the updated handle is to compare it, drop it,
195+ /// call this method again subject to both preconditions listed in the first point,
196+ /// or call counterpart `next_unchecked` subject to its preconditions .
195197 pub unsafe fn next_back_unchecked ( & mut self ) -> ( K , V ) {
196198 unsafe {
197199 replace ( self , |leaf_edge| {
0 commit comments