Skip to content

Commit

Permalink
list: Elide lifetime marks in rustc 1.83
Browse files Browse the repository at this point in the history
  • Loading branch information
XuShaohua committed Dec 9, 2024
1 parent 73b6b37 commit f731758
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
20 changes: 11 additions & 9 deletions list/src/doubly_linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,14 @@ impl<T> DoublyLinkedList<T> {
node = next_node;
}

unsafe { Self::insert_after(node, new_node_ptr); }
unsafe {
Self::insert_after(node, new_node_ptr);
}
self.len += 1;
}
}

pub fn insert_iter<I: IntoIterator<Item=T>>(&mut self, mut pos: usize, iter: I) {
pub fn insert_iter<I: IntoIterator<Item = T>>(&mut self, mut pos: usize, iter: I) {
assert!(pos <= self.len);
let mut new_list = DoublyLinkedList::from_iter(iter);

Expand Down Expand Up @@ -379,7 +381,7 @@ impl<T> DoublyLinkedList<T> {
pub fn splice(&mut self, _other: &mut Self) {
todo!()
}

/// Reverses the order of the elements.
pub fn reverse(&mut self) {
unsafe { Self::base_reverse(self.head) };
Expand Down Expand Up @@ -582,13 +584,13 @@ impl<T: Hash> Hash for DoublyLinkedList<T> {
}

impl<T> Extend<T> for DoublyLinkedList<T> {
fn extend<I: IntoIterator<Item=T>>(&mut self, iter: I) {
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
iter.into_iter().for_each(|value| self.push_back(value));
}
}

impl<T> FromIterator<T> for DoublyLinkedList<T> {
fn from_iter<I: IntoIterator<Item=T>>(iter: I) -> Self {
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
let mut list = Self::new();
list.extend(iter);
list
Expand Down Expand Up @@ -674,7 +676,7 @@ impl<'a, T> Iterator for Iter<'a, T> {
}
}

impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
impl<T> DoubleEndedIterator for Iter<'_, T> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.len == 0 {
None
Expand All @@ -689,7 +691,7 @@ impl<'a, T> DoubleEndedIterator for Iter<'a, T> {
}
}

impl<'a, T> ExactSizeIterator for Iter<'a, T> {}
impl<T> ExactSizeIterator for Iter<'_, T> {}

impl<'a, T> Iterator for IterMut<'a, T> {
type Item = &'a mut T;
Expand Down Expand Up @@ -721,7 +723,7 @@ impl<'a, T> Iterator for IterMut<'a, T> {
}
}

impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
impl<T> DoubleEndedIterator for IterMut<'_, T> {
fn next_back(&mut self) -> Option<Self::Item> {
if self.len == 0 {
None
Expand All @@ -736,7 +738,7 @@ impl<'a, T> DoubleEndedIterator for IterMut<'a, T> {
}
}

impl<'a, T> ExactSizeIterator for IterMut<'a, T> {}
impl<T> ExactSizeIterator for IterMut<'_, T> {}

impl<T> Node<T> {
#[must_use]
Expand Down
24 changes: 13 additions & 11 deletions matrix/src/linked_list_sparse_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ impl<T: IsZero> LinkedListSparseMatrix<T> {
#[must_use]
pub fn construct<I, I2>(sparse_matrix: I) -> Self
where
I: IntoIterator<Item=I2>,
I2: IntoIterator<Item=T>,
I: IntoIterator<Item = I2>,
I2: IntoIterator<Item = T>,
{
let mut head: NodePtr<T> = None;
let mut tail: NodePtr<T> = None;
Expand Down Expand Up @@ -179,7 +179,9 @@ impl<T: IsZero> LinkedListSparseMatrix<T> {
} else if index == len - 1 {
self.pop_back();
} else {
unsafe { Self::remove_node(node); }
unsafe {
Self::remove_node(node);
}
self.len -= 1;
}
return Some(value);
Expand Down Expand Up @@ -358,7 +360,7 @@ impl<'a, T: IsZero> Iterator for Iter<'a, T> {
}
}

impl<'a, T: IsZero> ExactSizeIterator for Iter<'a, T> {}
impl<T: IsZero> ExactSizeIterator for Iter<'_, T> {}

impl<'a, T: IsZero> Iterator for IterMut<'a, T> {
type Item = &'a mut Node<T>;
Expand All @@ -382,7 +384,7 @@ impl<'a, T: IsZero> Iterator for IterMut<'a, T> {
}
}

impl<'a, T: IsZero> ExactSizeIterator for IterMut<'a, T> {}
impl<T: IsZero> ExactSizeIterator for IterMut<'_, T> {}

impl<T: IsZero> Node<T> {
#[must_use]
Expand Down Expand Up @@ -440,7 +442,7 @@ mod tests {
[0, 0, 3, 0, 4],
[0, 0, 5, 7, 0],
[0, 0, 0, 0, 0],
[0, 2, 6, 0, 0]
[0, 2, 6, 0, 0],
];
let sm = LinkedListSparseMatrix::construct(MATRIX);
println!("sm: {sm:?}");
Expand Down Expand Up @@ -479,7 +481,7 @@ mod tests {
[0, 0, 3, 0, 4],
[0, 0, 5, 7, 0],
[0, 0, 0, 0, 0],
[0, 2, 6, 0, 0]
[0, 2, 6, 0, 0],
];
let sm = LinkedListSparseMatrix::construct(MATRIX);
assert_eq!(sm.value(0, 2), Some(3));
Expand All @@ -493,7 +495,7 @@ mod tests {
[0, 0, 3, 0, 4],
[0, 0, 5, 7, 0],
[0, 0, 0, 0, 0],
[0, 2, 6, 0, 0]
[0, 2, 6, 0, 0],
];
let mut sm = LinkedListSparseMatrix::construct(MATRIX);
let ret = sm.value_mut(0, 2);
Expand All @@ -509,7 +511,7 @@ mod tests {
[0, 0, 3, 0, 4],
[0, 0, 5, 7, 0],
[0, 0, 0, 0, 0],
[0, 2, 6, 0, 0]
[0, 2, 6, 0, 0],
];
let mut sm = LinkedListSparseMatrix::construct(MATRIX);
let ret = sm.add_element(1, 0, 1);
Expand All @@ -524,7 +526,7 @@ mod tests {
[0, 0, 3, 0, 4],
[0, 0, 5, 7, 0],
[0, 0, 0, 0, 0],
[0, 2, 6, 0, 0]
[0, 2, 6, 0, 0],
];
let mut sm = LinkedListSparseMatrix::construct(MATRIX);
let ret = sm.remove_element(1, 0);
Expand All @@ -533,4 +535,4 @@ mod tests {
assert_eq!(ret, Some(6));
assert_eq!(sm.len(), 5);
}
}
}
2 changes: 1 addition & 1 deletion vector/src/bitset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ pub struct BitSetIter<'a> {
index: usize,
}

impl<'a> Iterator for BitSetIter<'a> {
impl Iterator for BitSetIter<'_> {
type Item = bool;

fn next(&mut self) -> Option<Self::Item> {
Expand Down

0 comments on commit f731758

Please sign in to comment.