Skip to content

Commit 9924c67

Browse files
committed
Remove sorted_linked_list::Iter and sorted_linked_list::IterInner
1 parent 6ae82d5 commit 9924c67

File tree

1 file changed

+35
-40
lines changed

1 file changed

+35
-40
lines changed

src/sorted_linked_list.rs

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -468,30 +468,6 @@ where
468468
}
469469
}
470470

471-
/// Get an iterator over the sorted list.
472-
///
473-
/// # Example
474-
///
475-
/// ```
476-
/// use heapless::sorted_linked_list::{Max, SortedLinkedList};
477-
/// let mut ll: SortedLinkedList<_, _, Max, 3> = SortedLinkedList::new_usize();
478-
///
479-
/// ll.push(1).unwrap();
480-
/// ll.push(2).unwrap();
481-
///
482-
/// let mut iter = ll.iter();
483-
///
484-
/// assert_eq!(iter.next(), Some(&2));
485-
/// assert_eq!(iter.next(), Some(&1));
486-
/// assert_eq!(iter.next(), None);
487-
/// ```
488-
pub fn iter(&self) -> IterInner<'_, T, Idx, K, S> {
489-
IterInner {
490-
list: self,
491-
index: self.head,
492-
}
493-
}
494-
495471
/// Find an element in the list that can be changed and resorted.
496472
///
497473
/// # Example
@@ -663,33 +639,53 @@ where
663639
}
664640
}
665641

666-
/// Base struct for [`Iter`] and [`IterView`], generic over the [`SortedLinkedListStorage`].
667-
///
668-
/// In most cases you should use [`Iter`] or [`IterView`] directly. Only use this
669-
/// struct if you want to write code that's generic over both.
670-
pub struct IterInner<'a, T, Idx, K, S>
642+
impl<T, Idx, K> SortedLinkedListView<T, Idx, K>
671643
where
672644
T: Ord,
673645
Idx: SortedLinkedListIndex,
674646
K: Kind,
675-
S: SortedLinkedListStorage<T, Idx> + ?Sized,
676647
{
677-
list: &'a SortedLinkedListInner<T, Idx, K, S>,
678-
index: Idx,
648+
/// Get an iterator over the sorted list.
649+
///
650+
/// # Example
651+
///
652+
/// ```
653+
/// use heapless::sorted_linked_list::{Max, SortedLinkedList};
654+
/// let mut ll: SortedLinkedList<_, _, Max, 3> = SortedLinkedList::new_usize();
655+
///
656+
/// ll.push(1).unwrap();
657+
/// ll.push(2).unwrap();
658+
///
659+
/// let mut iter = ll.iter();
660+
///
661+
/// assert_eq!(iter.next(), Some(&2));
662+
/// assert_eq!(iter.next(), Some(&1));
663+
/// assert_eq!(iter.next(), None);
664+
/// ```
665+
pub fn iter(&self) -> IterView<'_, T, Idx, K> {
666+
IterView {
667+
list: self,
668+
index: self.head,
669+
}
670+
}
679671
}
680672

681673
/// Iterator for the linked list.
682-
pub type Iter<'a, T, Idx, K, const N: usize> =
683-
IterInner<'a, T, Idx, K, OwnedSortedLinkedListStorage<T, Idx, N>>;
684-
/// Iterator for the linked list.
685-
pub type IterView<'a, T, Idx, K> = IterInner<'a, T, Idx, K, ViewSortedLinkedListStorage<T, Idx>>;
674+
pub struct IterView<'a, T, Idx, K>
675+
where
676+
T: Ord,
677+
Idx: SortedLinkedListIndex,
678+
K: Kind,
679+
{
680+
list: &'a SortedLinkedListInner<T, Idx, K, ViewSortedLinkedListStorage<T, Idx>>,
681+
index: Idx,
682+
}
686683

687-
impl<'a, T, Idx, K, S> Iterator for IterInner<'a, T, Idx, K, S>
684+
impl<'a, T, Idx, K> Iterator for IterView<'a, T, Idx, K>
688685
where
689686
T: Ord,
690687
Idx: SortedLinkedListIndex,
691688
K: Kind,
692-
S: SortedLinkedListStorage<T, Idx> + ?Sized,
693689
{
694690
type Item = &'a T;
695691

@@ -887,12 +883,11 @@ where
887883
// }
888884
// }
889885

890-
impl<T, Idx, K, S> fmt::Debug for SortedLinkedListInner<T, Idx, K, S>
886+
impl<T, Idx, K> fmt::Debug for SortedLinkedListView<T, Idx, K>
891887
where
892888
T: Ord + core::fmt::Debug,
893889
Idx: SortedLinkedListIndex,
894890
K: Kind,
895-
S: SortedLinkedListStorage<T, Idx> + ?Sized,
896891
{
897892
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
898893
f.debug_list().entries(self.iter()).finish()

0 commit comments

Comments
 (0)