fix: no method name in too-many-lists

the Iterator implementation in too-many-lists/unsafe-queue/extra-junk.md, `as_ref`/`as_mut` should be used instead of `as_deref`/`as_deref_mut`, and wrap it with unsafe block.
pull/887/head
kosl90 3 years ago committed by GitHub
parent abf94cabe7
commit 95fc64b6c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -141,22 +141,26 @@ impl<'a, T> Iterator for Iter<'a, T> {
type Item = &'a T; type Item = &'a T;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
unsafe {
self.next.map(|node| { self.next.map(|node| {
self.next = node.next.as_deref(); self.next = node.next.as_ref();
&node.elem &node.elem
}) })
} }
}
} }
impl<'a, T> Iterator for IterMut<'a, T> { impl<'a, T> Iterator for IterMut<'a, T> {
type Item = &'a mut T; type Item = &'a mut T;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
unsafe {
self.next.take().map(|node| { self.next.take().map(|node| {
self.next = node.next.as_deref_mut(); self.next = node.next.as_mut();
&mut node.elem &mut node.elem
}) })
} }
}
} }
``` ```

Loading…
Cancel
Save