@@ -468,30 +468,6 @@ where
468
468
}
469
469
}
470
470
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
-
495
471
/// Find an element in the list that can be changed and resorted.
496
472
///
497
473
/// # Example
@@ -663,33 +639,53 @@ where
663
639
}
664
640
}
665
641
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 >
671
643
where
672
644
T : Ord ,
673
645
Idx : SortedLinkedListIndex ,
674
646
K : Kind ,
675
- S : SortedLinkedListStorage < T , Idx > + ?Sized ,
676
647
{
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
+ }
679
671
}
680
672
681
673
/// 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
+ }
686
683
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 >
688
685
where
689
686
T : Ord ,
690
687
Idx : SortedLinkedListIndex ,
691
688
K : Kind ,
692
- S : SortedLinkedListStorage < T , Idx > + ?Sized ,
693
689
{
694
690
type Item = & ' a T ;
695
691
@@ -887,12 +883,11 @@ where
887
883
// }
888
884
// }
889
885
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 >
891
887
where
892
888
T : Ord + core:: fmt:: Debug ,
893
889
Idx : SortedLinkedListIndex ,
894
890
K : Kind ,
895
- S : SortedLinkedListStorage < T , Idx > + ?Sized ,
896
891
{
897
892
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
898
893
f. debug_list ( ) . entries ( self . iter ( ) ) . finish ( )
0 commit comments