Skip to content

Commit 57058bf

Browse files
committed
CHANGE: WeakFixupFn for extend_from_slice()
1 parent ca899af commit 57058bf

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/lib.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -532,11 +532,21 @@ impl<H, T> HeaderVec<H, T> {
532532

533533
impl<H, T: Clone> HeaderVec<H, T> {
534534
/// Adds items from a slice to the end of the list.
535-
///
536-
/// Returns `Some(*const ())` if the memory was moved to a new location.
537-
/// In this case, you are responsible for updating the weak nodes.
538-
pub fn extend_from_slice(&mut self, slice: &[T]) -> Option<*const ()> {
539-
let previous_pointer = self.reserve(slice.len());
535+
pub fn extend_from_slice(&mut self, slice: &[T]) {
536+
self.extend_from_slice_intern(slice, None)
537+
}
538+
539+
540+
/// Adds items from a slice to the end of the list.
541+
/// This method must be used when `HeaderVecWeak` are used. It takes a closure that is responsible for
542+
/// updating the weak references as additional parameter.
543+
pub fn extend_from_slice_with_weakfix(&mut self, slice: &[T], weak_fixup: WeakFixupFn) {
544+
self.extend_from_slice_intern(slice, Some(weak_fixup));
545+
}
546+
547+
#[inline(always)]
548+
fn extend_from_slice_intern(&mut self, slice: &[T], weak_fixup: Option<WeakFixupFn>) {
549+
self.reserve_intern(slice.len(), false, weak_fixup);
540550

541551
// copy data
542552
let end_ptr = self.end_ptr_mut();
@@ -547,8 +557,6 @@ impl<H, T: Clone> HeaderVec<H, T> {
547557
}
548558
// correct the len
549559
self.header_mut().len = (self.len_exact() + slice.len()).into();
550-
551-
todo!("weak_fixup transformartion") // previous_pointer
552560
}
553561
}
554562

0 commit comments

Comments
 (0)