use super::super::AccountId;
#[derive(Clone, Copy, Debug)]
pub struct AccountHierarchyIter(Option<AccountId>);
impl Iterator for AccountHierarchyIter {
type Item = AccountId;
fn next(&mut self) -> Option<Self::Item> {
let current = self.0;
self.0 = self.0.and_then(AccountId::parent_id);
current
}
}
impl AccountHierarchyIter {
#[inline]
pub fn new(id: AccountId) -> Self {
Self(Some(id))
}
}