@@ -98,7 +98,7 @@ impl<Item, Gap, const CAP: usize> LinkedChunk<Item, Gap, CAP> {
98
98
if last_chunk. is_first_chunk ( ) . not ( ) {
99
99
// Maybe `last_chunk` is the same as the previous `self.last` chunk, but it's
100
100
// OK.
101
- self . last = Some ( NonNull :: from ( last_chunk) ) ;
101
+ self . last = Some ( last_chunk. as_ptr ( ) ) ;
102
102
}
103
103
104
104
self . length += number_of_items;
@@ -176,7 +176,7 @@ impl<Item, Gap, const CAP: usize> LinkedChunk<Item, Gap, CAP> {
176
176
if chunk. is_first_chunk ( ) . not ( ) && chunk. is_last_chunk ( ) {
177
177
// Maybe `chunk` is the same as the previous `self.last` chunk, but it's
178
178
// OK.
179
- self . last = Some ( NonNull :: from ( chunk) ) ;
179
+ self . last = Some ( chunk. as_ptr ( ) ) ;
180
180
}
181
181
182
182
self . length += number_of_items;
@@ -241,7 +241,7 @@ impl<Item, Gap, const CAP: usize> LinkedChunk<Item, Gap, CAP> {
241
241
if chunk. is_first_chunk ( ) . not ( ) && chunk. is_last_chunk ( ) {
242
242
// Maybe `chunk` is the same as the previous `self.last` chunk, but it's
243
243
// OK.
244
- self . last = Some ( NonNull :: from ( chunk) ) ;
244
+ self . last = Some ( chunk. as_ptr ( ) ) ;
245
245
}
246
246
247
247
Ok ( ( ) )
@@ -719,6 +719,11 @@ impl<Item, Gap, const CAPACITY: usize> Chunk<Item, Gap, CAPACITY> {
719
719
NonNull :: from ( Box :: leak ( chunk_box) )
720
720
}
721
721
722
+ /// Get the pointer to `Self`.
723
+ pub fn as_ptr ( & self ) -> NonNull < Self > {
724
+ NonNull :: from ( self )
725
+ }
726
+
722
727
/// Check whether this current chunk is a gap chunk.
723
728
pub fn is_gap ( & self ) -> bool {
724
729
matches ! ( self . content, ChunkContent :: Gap ( ..) )
@@ -848,7 +853,7 @@ impl<Item, Gap, const CAPACITY: usize> Chunk<Item, Gap, CAPACITY> {
848
853
// Link to the new chunk.
849
854
self . next = Some ( new_chunk_ptr) ;
850
855
// Link the new chunk to this one.
851
- new_chunk. previous = Some ( NonNull :: from ( self ) ) ;
856
+ new_chunk. previous = Some ( self . as_ptr ( ) ) ;
852
857
853
858
new_chunk
854
859
}
0 commit comments