diff --git a/cordyceps/src/list/tests.rs b/cordyceps/src/list/tests.rs index c6799730d..3e0881527 100644 --- a/cordyceps/src/list/tests.rs +++ b/cordyceps/src/list/tests.rs @@ -66,9 +66,12 @@ fn collect_vals(list: &List>) -> Vec { list.iter().map(|entry| entry.val).collect::>() } -fn push_all<'a>(list: &mut List>, entries: impl IntoIterator>>) { +fn push_all<'a>( + list: &mut List>, + entries: impl IntoIterator>>>, +) { for entry in entries.into_iter() { - list.push_front(entry); + list.push_back(entry.as_ref()); } } @@ -226,13 +229,11 @@ fn push_pop_push_pop() { #[test] fn double_ended_iter() { - let a = entry(1); - let b = entry(2); - let c = entry(3); + let entries = [entry(1), entry(2), entry(3)]; let mut list = List::new(); - push_all(&mut list, vec![c.as_ref(), b.as_ref(), a.as_ref()]); + push_all(&mut list, &entries); let head_to_tail = list.iter().map(|entry| entry.val).collect::>(); assert_eq!(&head_to_tail, &[1, 2, 3]); @@ -247,17 +248,11 @@ fn double_ended_iter() { /// > and do not cross: iteration is over when they meet in the middle. #[test] fn double_ended_iter_empties() { - let a = entry(1); - let b = entry(2); - let c = entry(3); - let d = entry(4); + let entries = [entry(1), entry(2), entry(3), entry(4)]; let mut list = List::new(); - push_all( - &mut list, - vec![d.as_ref(), c.as_ref(), b.as_ref(), a.as_ref()], - ); + push_all(&mut list, &entries); let mut iter = list.iter(); @@ -273,17 +268,11 @@ fn double_ended_iter_empties() { #[test] fn drain_filter() { - let a = entry(1); - let b = entry(2); - let c = entry(3); - let d = entry(4); + let entries = [entry(1), entry(2), entry(3), entry(4)]; let mut list = List::new(); - push_all( - &mut list, - vec![d.as_ref(), c.as_ref(), b.as_ref(), a.as_ref()], - ); + push_all(&mut list, &entries); { // Create a scope so that the mutable borrow on the list is released diff --git a/cordyceps/src/list/tests/cursor.rs b/cordyceps/src/list/tests/cursor.rs index 7997a5188..9f23a0183 100644 --- a/cordyceps/src/list/tests/cursor.rs +++ b/cordyceps/src/list/tests/cursor.rs @@ -7,10 +7,10 @@ use super::*; fn move_peek() { let _ = super::trace_init(); - let entries = &[entry(1), entry(2), entry(3), entry(4), entry(5), entry(6)]; + let entries = [entry(1), entry(2), entry(3), entry(4), entry(5), entry(6)]; let mut list = List::new(); - push_all(&mut list, entries.iter().map(|entry| entry.as_ref()).rev()); + push_all(&mut list, &entries); let mut cursor = list.cursor_front_mut(); assert_eq!(val(cursor.current()), Some(1)); assert_eq!(val(cursor.peek_next()), Some(2)); @@ -105,14 +105,14 @@ fn move_peek() { /// https://github.com/rust-lang/rust/blob/ec21d7ea3ca8e96863f175fbd4a6bfee79529d6c/library/alloc/src/collections/linked_list/tests.rs#L657-L714 #[test] fn cursor_mut_insert() { - let entries = &[entry(1), entry(2), entry(3), entry(4), entry(5), entry(6)]; + let entries = [entry(1), entry(2), entry(3), entry(4), entry(5), entry(6)]; let seven = entry(7); let eight = entry(8); let nine = entry(9); let ten = entry(10); let mut list = List::>::new(); - push_all(&mut list, entries.iter().map(|entry| entry.as_ref()).rev()); + push_all(&mut list, &entries); let mut cursor = list.cursor_front_mut(); cursor.insert_before(seven.as_ref()); diff --git a/cordyceps/src/list/tests/remove_by_addr.rs b/cordyceps/src/list/tests/remove_by_addr.rs index 4a6d4e22d..8966a059f 100644 --- a/cordyceps/src/list/tests/remove_by_addr.rs +++ b/cordyceps/src/list/tests/remove_by_addr.rs @@ -11,7 +11,7 @@ fn first() { // Remove first let mut list = List::new(); - push_all(&mut list, vec![c.as_ref(), b.as_ref(), a.as_ref()]); + push_all(&mut list, vec![&a, &b, &c]); assert!(list.remove(ptr(&a)).is_some()); assert_clean!(a); list.assert_valid(); @@ -43,7 +43,7 @@ fn first() { // Remove first of two let mut list = List::new(); - push_all(&mut list, vec![b.as_ref(), a.as_ref()]); + push_all(&mut list, vec![&a, &b]); assert!(list.remove(ptr(&a)).is_some()); assert_clean!(a); @@ -75,7 +75,7 @@ fn middle() { unsafe { let mut list = List::new(); - push_all(&mut list, vec![c.as_ref(), b.as_ref(), a.as_ref()]); + push_all(&mut list, vec![&a, &b, &c]); assert!(list.remove(ptr(&a)).is_some()); assert_clean!(a); @@ -93,7 +93,7 @@ fn middle() { unsafe { let mut list = List::new(); - push_all(&mut list, vec![c.as_ref(), b.as_ref(), a.as_ref()]); + push_all(&mut list, vec![&a, &b, &c]); assert!(list.remove(ptr(&b)).is_some()); assert_clean!(b); @@ -120,7 +120,7 @@ fn last_middle() { // Remove middle let mut list = List::new(); - push_all(&mut list, vec![c.as_ref(), b.as_ref(), a.as_ref()]); + push_all(&mut list, vec![&a, &b, &c]); assert!(list.remove(ptr(&c)).is_some()); assert_clean!(c); @@ -145,7 +145,7 @@ fn last() { // Remove last item let mut list = List::new(); - push_all(&mut list, Some(a.as_ref())); + push_all(&mut list, Some(&a)); assert!(list.remove(ptr(&a)).is_some()); assert_clean!(a); @@ -161,7 +161,7 @@ fn last() { // Remove last of two let mut list = List::new(); - push_all(&mut list, vec![b.as_ref(), a.as_ref()]); + push_all(&mut list, vec![&a, &b]); assert!(list.remove(ptr(&b)).is_some()); assert_clean!(b);