@@ -113,7 +113,7 @@ pub trait ZipperSubtries<V: Clone + Send + Sync>: ZipperValues<V> + zipper_priv:
113113/// A zipper's **origin** is always equal-to-or-above the zipper's root. The position of the origin depends
114114/// on how the zipper was created, and the origin will never be below the root. The origin of a given zipper
115115/// will never change.
116- pub trait ZipperMoving : Zipper + ZipperMovingPriv {
116+ pub trait ZipperMoving : Zipper {
117117 /// Returns `true` if the zipper's focus is at its root, and it cannot ascend further, otherwise returns `false`
118118 fn at_root ( & self ) -> bool {
119119 self . path ( ) . len ( ) == 0
@@ -501,6 +501,24 @@ pub trait ZipperConcrete: zipper_priv::ZipperConcretePriv {
501501 fn is_shared ( & self ) -> bool ;
502502}
503503
504+ /// Provides more direct control over a [ZipperMoving] zipper's path buffer
505+ pub trait ZipperPathBuffer : ZipperMoving {
506+ /// Internal method to get the path, beyond its length. Panics if `len` > the path's capacity, or
507+ /// if the zipper is relative and doesn't have an `origin_path`
508+ ///
509+ /// This method is unsafe because it relies on the caller to not read uninitialized memory, even if
510+ /// the memory has been allocated.
511+ unsafe fn origin_path_assert_len ( & self , len : usize ) -> & [ u8 ] ;
512+
513+ /// Make sure the path buffer is allocated, to facilitate zipper movement
514+ fn prepare_buffers ( & mut self ) ;
515+
516+ /// Reserve buffer space within the zipper's path buffer and node stack
517+ ///
518+ /// This method will only grow the buffers and will never shrink them.
519+ fn reserve_buffers ( & mut self , path_len : usize , stack_depth : usize ) ;
520+ }
521+
504522pub ( crate ) mod zipper_priv {
505523 use super :: * ;
506524
@@ -547,23 +565,6 @@ pub(crate) mod zipper_priv {
547565 fn try_borrow_focus ( & self ) -> Option < & dyn TrieNode < Self :: V > > ;
548566 }
549567
550- pub trait ZipperMovingPriv {
551- /// Internal method to get the path, beyond its length. Panics if `len` > the path's capacity, or
552- /// if the zipper is relative and doesn't have an `origin_path`
553- ///
554- /// This method is unsafe because it relies on the caller to not read uninitialized memory, even if
555- /// the memory has been allocated.
556- unsafe fn origin_path_assert_len ( & self , len : usize ) -> & [ u8 ] ;
557-
558- /// Make sure the path buffer is allocated, to facilitate zipper movement
559- fn prepare_buffers ( & mut self ) ;
560-
561- /// Reserve buffer space within the zipper's path buffer and node stack
562- ///
563- /// This method will only grow the buffers and will never shrink them.
564- fn reserve_buffers ( & mut self , path_len : usize , stack_depth : usize ) ;
565- }
566-
567568 pub trait ZipperReadOnlyPriv < ' a , V : Clone + Send + Sync > {
568569 /// Internal method returns the minimal components that compose the zipper, which are:
569570 ///
@@ -595,7 +596,7 @@ pub(crate) mod zipper_priv {
595596 }
596597}
597598use zipper_priv:: * ;
598- pub use zipper_priv:: { ZipperMovingPriv , ZipperConcretePriv } ;
599+ pub use zipper_priv:: ZipperConcretePriv ;
599600
600601impl < Z > Zipper for & mut Z where Z : Zipper {
601602 fn path_exists ( & self ) -> bool { ( * * self ) . path_exists ( ) }
@@ -671,7 +672,7 @@ impl<V: Clone + Send + Sync, Z> ZipperPriv for &mut Z where Z: ZipperPriv<V=V> {
671672 fn try_borrow_focus ( & self ) -> Option < & dyn TrieNode < Self :: V > > { ( * * self ) . try_borrow_focus ( ) }
672673}
673674
674- impl < Z > ZipperMovingPriv for & mut Z where Z : ZipperMovingPriv {
675+ impl < Z > ZipperPathBuffer for & mut Z where Z : ZipperPathBuffer {
675676 unsafe fn origin_path_assert_len ( & self , len : usize ) -> & [ u8 ] { ( * * self ) . origin_path_assert_len ( len) }
676677 fn prepare_buffers ( & mut self ) { ( * * self ) . prepare_buffers ( ) }
677678 fn reserve_buffers ( & mut self , path_len : usize , stack_depth : usize ) { ( * * self ) . reserve_buffers ( path_len, stack_depth) }
@@ -781,7 +782,7 @@ impl<V: Clone + Send + Sync + Unpin> zipper_priv::ZipperPriv for ReadZipperTrack
781782 fn try_borrow_focus ( & self ) -> Option < & dyn TrieNode < Self :: V > > { self . z . try_borrow_focus ( ) }
782783}
783784
784- impl < V : Clone + Send + Sync + Unpin > zipper_priv :: ZipperMovingPriv for ReadZipperTracked < ' _ , ' _ , V > {
785+ impl < V : Clone + Send + Sync + Unpin > ZipperPathBuffer for ReadZipperTracked < ' _ , ' _ , V > {
785786 unsafe fn origin_path_assert_len ( & self , len : usize ) -> & [ u8 ] { unsafe { self . z . origin_path_assert_len ( len) } }
786787 fn prepare_buffers ( & mut self ) { self . z . prepare_buffers ( ) }
787788 fn reserve_buffers ( & mut self , path_len : usize , stack_depth : usize ) { self . z . reserve_buffers ( path_len, stack_depth) }
@@ -931,7 +932,7 @@ impl<V: Clone + Send + Sync + Unpin> zipper_priv::ZipperPriv for ReadZipperUntra
931932 fn try_borrow_focus ( & self ) -> Option < & dyn TrieNode < Self :: V > > { self . z . try_borrow_focus ( ) }
932933}
933934
934- impl < V : Clone + Send + Sync + Unpin > zipper_priv :: ZipperMovingPriv for ReadZipperUntracked < ' _ , ' _ , V > {
935+ impl < V : Clone + Send + Sync + Unpin > ZipperPathBuffer for ReadZipperUntracked < ' _ , ' _ , V > {
935936 unsafe fn origin_path_assert_len ( & self , len : usize ) -> & [ u8 ] { unsafe { self . z . origin_path_assert_len ( len) } }
936937 fn prepare_buffers ( & mut self ) { self . z . prepare_buffers ( ) }
937938 fn reserve_buffers ( & mut self , path_len : usize , stack_depth : usize ) { self . z . reserve_buffers ( path_len, stack_depth) }
@@ -1130,7 +1131,7 @@ impl<V: Clone + Send + Sync + Unpin> zipper_priv::ZipperPriv for ReadZipperOwned
11301131 fn try_borrow_focus ( & self ) -> Option < & dyn TrieNode < Self :: V > > { self . z . try_borrow_focus ( ) }
11311132}
11321133
1133- impl < V : Clone + Send + Sync + Unpin > zipper_priv :: ZipperMovingPriv for ReadZipperOwned < V > {
1134+ impl < V : Clone + Send + Sync + Unpin > ZipperPathBuffer for ReadZipperOwned < V > {
11341135 unsafe fn origin_path_assert_len ( & self , len : usize ) -> & [ u8 ] { unsafe { self . z . origin_path_assert_len ( len) } }
11351136 fn prepare_buffers ( & mut self ) { self . z . prepare_buffers ( ) }
11361137 fn reserve_buffers ( & mut self , path_len : usize , stack_depth : usize ) { self . z . reserve_buffers ( path_len, stack_depth) }
@@ -1617,7 +1618,7 @@ pub(crate) mod read_zipper_core {
16171618 }
16181619 }
16191620
1620- impl < V : Clone + Send + Sync + Unpin > zipper_priv :: ZipperMovingPriv for ReadZipperCore < ' _ , ' _ , V > {
1621+ impl < V : Clone + Send + Sync + Unpin > ZipperPathBuffer for ReadZipperCore < ' _ , ' _ , V > {
16211622 unsafe fn origin_path_assert_len ( & self , len : usize ) -> & [ u8 ] {
16221623 if self . prefix_buf . capacity ( ) > 0 {
16231624 assert ! ( len <= self . prefix_buf. capacity( ) ) ;
0 commit comments