@@ -142,7 +142,7 @@ impl<T> LinkedList<T> {
142
142
143
143
match self . head {
144
144
None => self . tail = node,
145
- Some ( head) => ( * * head) . prev = node,
145
+ Some ( head) => ( * head. as_mut_ptr ( ) ) . prev = node,
146
146
}
147
147
148
148
self . head = node;
@@ -154,12 +154,12 @@ impl<T> LinkedList<T> {
154
154
#[ inline]
155
155
fn pop_front_node ( & mut self ) -> Option < Box < Node < T > > > {
156
156
self . head . map ( |node| unsafe {
157
- let node = Box :: from_raw ( * node) ;
157
+ let node = Box :: from_raw ( node. as_mut_ptr ( ) ) ;
158
158
self . head = node. next ;
159
159
160
160
match self . head {
161
161
None => self . tail = None ,
162
- Some ( head) => ( * * head) . prev = None ,
162
+ Some ( head) => ( * head. as_mut_ptr ( ) ) . prev = None ,
163
163
}
164
164
165
165
self . len -= 1 ;
@@ -177,7 +177,7 @@ impl<T> LinkedList<T> {
177
177
178
178
match self . tail {
179
179
None => self . head = node,
180
- Some ( tail) => ( * * tail) . next = node,
180
+ Some ( tail) => ( * tail. as_mut_ptr ( ) ) . next = node,
181
181
}
182
182
183
183
self . tail = node;
@@ -189,12 +189,12 @@ impl<T> LinkedList<T> {
189
189
#[ inline]
190
190
fn pop_back_node ( & mut self ) -> Option < Box < Node < T > > > {
191
191
self . tail . map ( |node| unsafe {
192
- let node = Box :: from_raw ( * node) ;
192
+ let node = Box :: from_raw ( node. as_mut_ptr ( ) ) ;
193
193
self . tail = node. prev ;
194
194
195
195
match self . tail {
196
196
None => self . head = None ,
197
- Some ( tail) => ( * * tail) . next = None ,
197
+ Some ( tail) => ( * tail. as_mut_ptr ( ) ) . next = None ,
198
198
}
199
199
200
200
self . len -= 1 ;
@@ -269,8 +269,8 @@ impl<T> LinkedList<T> {
269
269
Some ( tail) => {
270
270
if let Some ( other_head) = other. head . take ( ) {
271
271
unsafe {
272
- ( * * tail) . next = Some ( other_head) ;
273
- ( * * other_head) . prev = Some ( tail) ;
272
+ ( * tail. as_mut_ptr ( ) ) . next = Some ( other_head) ;
273
+ ( * other_head. as_mut_ptr ( ) ) . prev = Some ( tail) ;
274
274
}
275
275
276
276
self . tail = other. tail . take ( ) ;
@@ -484,7 +484,7 @@ impl<T> LinkedList<T> {
484
484
#[ inline]
485
485
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
486
486
pub fn front_mut ( & mut self ) -> Option < & mut T > {
487
- self . head . map ( |node| unsafe { & mut ( * * node) . element } )
487
+ self . head . map ( |node| unsafe { & mut ( * node. as_mut_ptr ( ) ) . element } )
488
488
}
489
489
490
490
/// Provides a reference to the back element, or `None` if the list is
@@ -530,7 +530,7 @@ impl<T> LinkedList<T> {
530
530
#[ inline]
531
531
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
532
532
pub fn back_mut ( & mut self ) -> Option < & mut T > {
533
- self . tail . map ( |node| unsafe { & mut ( * * node) . element } )
533
+ self . tail . map ( |node| unsafe { & mut ( * node. as_mut_ptr ( ) ) . element } )
534
534
}
535
535
536
536
/// Adds an element first in the list.
@@ -675,9 +675,9 @@ impl<T> LinkedList<T> {
675
675
let second_part_head;
676
676
677
677
unsafe {
678
- second_part_head = ( * * split_node. unwrap ( ) ) . next . take ( ) ;
678
+ second_part_head = ( * split_node. unwrap ( ) . as_mut_ptr ( ) ) . next . take ( ) ;
679
679
if let Some ( head) = second_part_head {
680
- ( * * head) . prev = None ;
680
+ ( * head. as_mut_ptr ( ) ) . prev = None ;
681
681
}
682
682
}
683
683
@@ -816,7 +816,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
816
816
None
817
817
} else {
818
818
self . head . map ( |node| unsafe {
819
- let node = & mut * * node;
819
+ let node = & mut * node. as_mut_ptr ( ) ;
820
820
self . len -= 1 ;
821
821
self . head = node. next ;
822
822
& mut node. element
@@ -838,7 +838,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
838
838
None
839
839
} else {
840
840
self . tail . map ( |node| unsafe {
841
- let node = & mut * * node;
841
+ let node = & mut * node. as_mut_ptr ( ) ;
842
842
self . len -= 1 ;
843
843
self . tail = node. prev ;
844
844
& mut node. element
@@ -896,8 +896,8 @@ impl<'a, T> IterMut<'a, T> {
896
896
element : element,
897
897
} ) ) ) ;
898
898
899
- ( * * prev) . next = node;
900
- ( * * head) . prev = node;
899
+ ( * prev. as_mut_ptr ( ) ) . next = node;
900
+ ( * head. as_mut_ptr ( ) ) . prev = node;
901
901
902
902
self . list . len += 1 ;
903
903
} ,
@@ -929,7 +929,7 @@ impl<'a, T> IterMut<'a, T> {
929
929
if self . len == 0 {
930
930
None
931
931
} else {
932
- self . head . map ( |node| unsafe { & mut ( * * node) . element } )
932
+ self . head . map ( |node| unsafe { & mut ( * node. as_mut_ptr ( ) ) . element } )
933
933
}
934
934
}
935
935
}
0 commit comments