File tree Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Expand file tree Collapse file tree 1 file changed +4
-13
lines changed Original file line number Diff line number Diff line change @@ -122,31 +122,22 @@ impl<T> Mutable for DList<T> {
122
122
impl < T > Deque < T > for DList < T > {
123
123
/// Provide a reference to the front element, or None if the list is empty
124
124
fn front < ' a > ( & ' a self ) -> Option < & ' a T > {
125
- self . list_head . chain_ref ( |x| Some ( & x . value ) )
125
+ self . list_head . map ( |head| & head . value )
126
126
}
127
127
128
128
/// Provide a mutable reference to the front element, or None if the list is empty
129
129
fn front_mut < ' a > ( & ' a mut self ) -> Option < & ' a mut T > {
130
- match self . list_head {
131
- None => None ,
132
- Some ( ref mut head) => Some ( & mut head. value ) ,
133
- }
130
+ self . list_head . map_mut ( |head| & mut head. value )
134
131
}
135
132
136
133
/// Provide a reference to the back element, or None if the list is empty
137
134
fn back < ' a > ( & ' a self ) -> Option < & ' a T > {
138
- match self . list_tail . resolve_immut ( ) {
139
- None => None ,
140
- Some ( tail) => Some ( & tail. value ) ,
141
- }
135
+ self . list_tail . resolve_immut ( ) . map ( |tail| & tail. value )
142
136
}
143
137
144
138
/// Provide a mutable reference to the back element, or None if the list is empty
145
139
fn back_mut < ' a > ( & ' a mut self ) -> Option < & ' a mut T > {
146
- match self . list_tail . resolve ( ) {
147
- None => None ,
148
- Some ( tail) => Some ( & mut tail. value ) ,
149
- }
140
+ self . list_tail . resolve ( ) . map_mut ( |tail| & mut tail. value )
150
141
}
151
142
152
143
/// Add an element last in the list
You can’t perform that action at this time.
0 commit comments