|
@@ -35,7 +35,7 @@ impl<T> List<T> {
|
|
|
}
|
|
}
|
|
|
impl<T> Default for List<T> {
|
|
impl<T> Default for List<T> {
|
|
|
fn default() -> Self {
|
|
fn default() -> Self {
|
|
|
- Self { head: None }
|
|
|
|
|
|
|
+ Self::new()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
impl<T> Drop for List<T> {
|
|
impl<T> Drop for List<T> {
|
|
@@ -74,7 +74,7 @@ pub struct Iter<'a, T> {
|
|
|
next: Option<&'a Node<T>>,
|
|
next: Option<&'a Node<T>>,
|
|
|
}
|
|
}
|
|
|
impl<T> List<T> {
|
|
impl<T> List<T> {
|
|
|
- pub fn iter<'a>(&'a self) -> Iter<'a, T> {
|
|
|
|
|
|
|
+ pub fn iter(&self) -> Iter<'_, T> {
|
|
|
Iter {
|
|
Iter {
|
|
|
next: self.head.as_deref(),
|
|
next: self.head.as_deref(),
|
|
|
}
|
|
}
|
|
@@ -83,7 +83,7 @@ impl<T> List<T> {
|
|
|
impl<'a, T> Iterator for Iter<'a, T> {
|
|
impl<'a, T> Iterator for Iter<'a, T> {
|
|
|
type Item = &'a T;
|
|
type Item = &'a T;
|
|
|
|
|
|
|
|
- fn next<'b>(&'b mut self) -> Option<Self::Item> {
|
|
|
|
|
|
|
+ fn next(&mut self) -> Option<Self::Item> {
|
|
|
self.next.map(|node| {
|
|
self.next.map(|node| {
|
|
|
self.next = node.next.as_deref();
|
|
self.next = node.next.as_deref();
|
|
|
&node.elem
|
|
&node.elem
|
|
@@ -94,7 +94,7 @@ pub struct IterMut<'a, T> {
|
|
|
next: Option<&'a mut Node<T>>,
|
|
next: Option<&'a mut Node<T>>,
|
|
|
}
|
|
}
|
|
|
impl<T> List<T> {
|
|
impl<T> List<T> {
|
|
|
- pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
|
|
|
|
|
|
|
+ pub fn iter_mut(&mut self) -> IterMut<'_, T> {
|
|
|
IterMut {
|
|
IterMut {
|
|
|
next: self.head.as_deref_mut(),
|
|
next: self.head.as_deref_mut(),
|
|
|
}
|
|
}
|
|
@@ -103,7 +103,7 @@ impl<T> List<T> {
|
|
|
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<'b>(&'b mut self) -> Option<Self::Item> {
|
|
|
|
|
|
|
+ fn next(&mut self) -> Option<Self::Item> {
|
|
|
self.next.take().map(|node| {
|
|
self.next.take().map(|node| {
|
|
|
self.next = node.next.as_deref_mut();
|
|
self.next = node.next.as_deref_mut();
|
|
|
&mut node.elem
|
|
&mut node.elem
|