@@ -376,18 +376,26 @@ impl<H, T> HeaderVec<H, T> {
376376 }
377377
378378 /// Adds an item to the end of the list.
379- ///
380- /// Returns `Some(*const ())` if the memory was moved to a new location.
381- /// In this case, you are responsible for updating the weak nodes.
382- pub fn push ( & mut self , item : T ) -> Option < * const ( ) > {
379+ pub fn push ( & mut self , item : T ) {
380+ self . push_intern ( item, None ) ;
381+ }
382+
383+ /// Adds an item to the end of the list.
384+ /// This method must be used when `HeaderVecWeak` are used. It takes a closure that is responsible for
385+ /// updating the weak references as additional parameter.
386+ pub fn push_with_weakfix ( & mut self , item : T , weak_fixup : WeakFixupFn ) {
387+ self . push_intern ( item, Some ( weak_fixup) ) ;
388+ }
389+
390+ #[ inline( always) ]
391+ fn push_intern ( & mut self , item : T , weak_fixup : Option < WeakFixupFn > ) {
383392 let old_len = self . len_exact ( ) ;
384393 let new_len = old_len + 1 ;
385- let previous_pointer = self . reserve ( 1 ) ;
394+ self . reserve_intern ( 1 , false , weak_fixup ) ;
386395 unsafe {
387396 core:: ptr:: write ( self . as_mut_ptr ( ) . add ( old_len) , item) ;
388397 }
389398 self . header_mut ( ) . len = new_len. into ( ) ;
390- todo ! ( "weak_fixup transformartion" ) // previous_pointer
391399 }
392400
393401 /// Retains only the elements specified by the predicate.
0 commit comments