diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /compiler/rustc_data_structures/src/tiny_list.rs | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_data_structures/src/tiny_list.rs')
-rw-r--r-- | compiler/rustc_data_structures/src/tiny_list.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/rustc_data_structures/src/tiny_list.rs b/compiler/rustc_data_structures/src/tiny_list.rs index 9b07f8684..11a408f21 100644 --- a/compiler/rustc_data_structures/src/tiny_list.rs +++ b/compiler/rustc_data_structures/src/tiny_list.rs @@ -37,9 +37,9 @@ impl<T: PartialEq> TinyList<T> { #[inline] pub fn remove(&mut self, data: &T) -> bool { - self.head = match self.head { - Some(ref mut head) if head.data == *data => head.next.take().map(|x| *x), - Some(ref mut head) => return head.remove_next(data), + self.head = match &mut self.head { + Some(head) if head.data == *data => head.next.take().map(|x| *x), + Some(head) => return head.remove_next(data), None => return false, }; true @@ -48,7 +48,7 @@ impl<T: PartialEq> TinyList<T> { #[inline] pub fn contains(&self, data: &T) -> bool { let mut elem = self.head.as_ref(); - while let Some(ref e) = elem { + while let Some(e) = elem { if &e.data == data { return true; } @@ -65,15 +65,14 @@ struct Element<T> { } impl<T: PartialEq> Element<T> { - fn remove_next(&mut self, data: &T) -> bool { - let mut n = self; + fn remove_next(mut self: &mut Self, data: &T) -> bool { loop { - match n.next { + match self.next { Some(ref mut next) if next.data == *data => { - n.next = next.next.take(); + self.next = next.next.take(); return true; } - Some(ref mut next) => n = next, + Some(ref mut next) => self = next, None => return false, } } |