add iter-from for bags-list (#11104)

* add iter-from for bags-list

* Fix

* Apply suggestions from code review

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Kian Paimani
2022-03-31 15:16:34 +01:00
committed by GitHub
parent 6ec4ee1647
commit c2d3d488b8
5 changed files with 79 additions and 2 deletions
+7 -1
View File
@@ -271,13 +271,19 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
impl<T: Config<I>, I: 'static> SortedListProvider<T::AccountId> for Pallet<T, I> {
type Error = ListError;
type Score = T::Score;
fn iter() -> Box<dyn Iterator<Item = T::AccountId>> {
Box::new(List::<T, I>::iter().map(|n| n.id().clone()))
}
fn iter_from(
start: &T::AccountId,
) -> Result<Box<dyn Iterator<Item = T::AccountId>>, Self::Error> {
let iter = List::<T, I>::iter_from(start)?;
Ok(Box::new(iter.map(|n| n.id().clone())))
}
fn count() -> u32 {
ListNodes::<T, I>::count()
}