@@ -165,7 +165,7 @@ impl<T> DList<T> {
165
165
/// Remove the first Node and return it, or None if the list is empty
166
166
#[ inline]
167
167
fn pop_front_node ( & mut self ) -> Option < ~Node < T > > {
168
- do self . list_head . take ( ) . map_move |mut front_node| {
168
+ do self . list_head . take ( ) . map |mut front_node| {
169
169
self . length -= 1 ;
170
170
match front_node. next . take ( ) {
171
171
Some ( node) => self . list_head = link_with_prev ( node, Rawlink :: none ( ) ) ,
@@ -191,7 +191,7 @@ impl<T> DList<T> {
191
191
/// Remove the last Node and return it, or None if the list is empty
192
192
#[ inline]
193
193
fn pop_back_node ( & mut self ) -> Option < ~Node < T > > {
194
- do self . list_tail . resolve ( ) . map_move_default ( None ) |tail| {
194
+ do self . list_tail . resolve ( ) . map_default ( None ) |tail| {
195
195
self . length -= 1 ;
196
196
self . list_tail = tail. prev ;
197
197
match tail. prev . resolve ( ) {
@@ -206,25 +206,27 @@ impl<T> Deque<T> for DList<T> {
206
206
/// Provide a reference to the front element, or None if the list is empty
207
207
#[ inline]
208
208
fn front < ' a > ( & ' a self ) -> Option < & ' a T > {
209
- self . list_head . map ( |head| & head. value )
209
+ self . list_head . as_ref ( ) . map ( |head| & head. value )
210
210
}
211
211
212
212
/// Provide a mutable reference to the front element, or None if the list is empty
213
213
#[ inline]
214
214
fn front_mut < ' a > ( & ' a mut self ) -> Option < & ' a mut T > {
215
- self . list_head . map_mut ( |head| & mut head. value )
215
+ self . list_head . as_mut ( ) . map ( |head| & mut head. value )
216
216
}
217
217
218
218
/// Provide a reference to the back element, or None if the list is empty
219
219
#[ inline]
220
220
fn back < ' a > ( & ' a self ) -> Option < & ' a T > {
221
- self . list_tail . resolve_immut ( ) . map ( |tail| & tail. value )
221
+ let tmp = self . list_tail . resolve_immut ( ) ; // FIXME: #3511: shouldn't need variable
222
+ tmp. as_ref ( ) . map ( |tail| & tail. value )
222
223
}
223
224
224
225
/// Provide a mutable reference to the back element, or None if the list is empty
225
226
#[ inline]
226
227
fn back_mut < ' a > ( & ' a mut self ) -> Option < & ' a mut T > {
227
- self . list_tail . resolve ( ) . map_mut ( |tail| & mut tail. value )
228
+ let mut tmp = self . list_tail . resolve ( ) ; // FIXME: #3511: shouldn't need variable
229
+ tmp. as_mut ( ) . map ( |tail| & mut tail. value )
228
230
}
229
231
230
232
/// Add an element first in the list
@@ -238,7 +240,7 @@ impl<T> Deque<T> for DList<T> {
238
240
///
239
241
/// O(1)
240
242
fn pop_front ( & mut self ) -> Option < T > {
241
- self . pop_front_node ( ) . map_move ( |~Node { value, _} | value)
243
+ self . pop_front_node ( ) . map ( |~Node { value, _} | value)
242
244
}
243
245
244
246
/// Add an element last in the list
@@ -252,7 +254,7 @@ impl<T> Deque<T> for DList<T> {
252
254
///
253
255
/// O(1)
254
256
fn pop_back ( & mut self ) -> Option < T > {
255
- self . pop_back_node ( ) . map_move ( |~Node { value, _} | value)
257
+ self . pop_back_node ( ) . map ( |~Node { value, _} | value)
256
258
}
257
259
}
258
260
@@ -268,7 +270,7 @@ impl<T> DList<T> {
268
270
/// If the list is empty, do nothing.
269
271
#[ inline]
270
272
pub fn rotate_forward ( & mut self ) {
271
- do self . pop_back_node ( ) . map_move |tail| {
273
+ do self . pop_back_node ( ) . map |tail| {
272
274
self . push_front_node ( tail)
273
275
} ;
274
276
}
@@ -278,7 +280,7 @@ impl<T> DList<T> {
278
280
/// If the list is empty, do nothing.
279
281
#[ inline]
280
282
pub fn rotate_backward ( & mut self ) {
281
- do self . pop_front_node ( ) . map_move |head| {
283
+ do self . pop_front_node ( ) . map |head| {
282
284
self . push_back_node ( head)
283
285
} ;
284
286
}
@@ -442,7 +444,7 @@ impl<'self, A> Iterator<&'self A> for DListIterator<'self, A> {
442
444
if self . nelem == 0 {
443
445
return None ;
444
446
}
445
- do self. head . map |head| {
447
+ do self. head . as_ref ( ) . map |head| {
446
448
self . nelem -= 1 ;
447
449
self . head = & head. next ;
448
450
& head. value
@@ -461,7 +463,8 @@ impl<'self, A> DoubleEndedIterator<&'self A> for DListIterator<'self, A> {
461
463
if self . nelem == 0 {
462
464
return None ;
463
465
}
464
- do self. tail . resolve ( ) . map_move |prev| {
466
+ let tmp = self . tail . resolve_immut ( ) ; // FIXME: #3511: shouldn't need variable
467
+ do tmp. as_ref ( ) . map |prev| {
465
468
self . nelem -= 1 ;
466
469
self . tail = prev. prev ;
467
470
& prev. value
@@ -477,7 +480,7 @@ impl<'self, A> Iterator<&'self mut A> for MutDListIterator<'self, A> {
477
480
if self . nelem == 0 {
478
481
return None ;
479
482
}
480
- do self. head . resolve ( ) . map_move |next| {
483
+ do self. head . resolve ( ) . map |next| {
481
484
self . nelem -= 1 ;
482
485
self . head = match next. next {
483
486
Some ( ref mut node) => Rawlink :: some ( & mut * * node) ,
@@ -499,7 +502,7 @@ impl<'self, A> DoubleEndedIterator<&'self mut A> for MutDListIterator<'self, A>
499
502
if self . nelem == 0 {
500
503
return None ;
501
504
}
502
- do self. tail . resolve ( ) . map_move |prev| {
505
+ do self. tail . resolve ( ) . map |prev| {
503
506
self . nelem -= 1 ;
504
507
self . tail = prev. prev ;
505
508
& mut prev. value
@@ -554,7 +557,7 @@ impl<'self, A> ListInsertion<A> for MutDListIterator<'self, A> {
554
557
if self . nelem == 0 {
555
558
return None
556
559
}
557
- self . head . resolve ( ) . map_move ( |head| & mut head. value )
560
+ self . head . resolve ( ) . map ( |head| & mut head. value )
558
561
}
559
562
}
560
563
0 commit comments