Skip to content

Commit 85f1aea

Browse files
committed
Make implementations generic over the storage
1 parent e395892 commit 85f1aea

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/sorted_linked_list.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,12 @@ where
581581
}
582582
}
583583

584-
impl<T, Idx, K> SortedLinkedListView<T, Idx, K>
584+
impl<T, Idx, K, S> SortedLinkedListInner<T, Idx, K, S>
585585
where
586586
T: Ord,
587587
Idx: SortedLinkedListIndex,
588588
K: Kind,
589+
S: SortedLinkedListStorage<T, Idx> + ?Sized,
589590
{
590591
/// Get an iterator over the sorted list.
591592
///
@@ -606,7 +607,7 @@ where
606607
/// ```
607608
pub fn iter(&self) -> IterView<'_, T, Idx, K> {
608609
IterView {
609-
list: self,
610+
list: S::as_view(self),
610611
index: self.head,
611612
}
612613
}
@@ -645,7 +646,7 @@ where
645646
is_head: true,
646647
prev_index: Idx::none(),
647648
index: self.head,
648-
list: self,
649+
list: S::as_mut_view(self),
649650
maybe_changed: false,
650651
});
651652
}
@@ -658,7 +659,7 @@ where
658659
is_head: false,
659660
prev_index: unsafe { Idx::new_unchecked(current) },
660661
index: unsafe { Idx::new_unchecked(next) },
661-
list: self,
662+
list: S::as_mut_view(self),
662663
maybe_changed: false,
663664
});
664665
}
@@ -868,11 +869,12 @@ where
868869
// }
869870
// }
870871

871-
impl<T, Idx, K> fmt::Debug for SortedLinkedListView<T, Idx, K>
872+
impl<T, Idx, K, S> fmt::Debug for SortedLinkedListInner<T, Idx, K, S>
872873
where
873874
T: Ord + core::fmt::Debug,
874875
Idx: SortedLinkedListIndex,
875876
K: Kind,
877+
S: ?Sized + SortedLinkedListStorage<T, Idx>,
876878
{
877879
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
878880
f.debug_list().entries(self.iter()).finish()

0 commit comments

Comments
 (0)