use crate::{Cons, HList, Nil};
use super::{Index, ManyIndex, Remove};
pub trait RemoveMany<T, I>: HList
where
T: HList,
I: ManyIndex,
{
type Remainder: HList;
fn remove_many(self) -> (T, Self::Remainder);
}
impl<T> RemoveMany<Nil, Nil> for T
where
T: HList,
{
type Remainder = Self;
fn remove_many(self) -> (Nil, Self::Remainder) {
(Nil, self)
}
}
impl<Head, Tail, OtherHead, OtherTail, IndexHead, IndexTail>
RemoveMany<Cons<OtherHead, OtherTail>, Cons<IndexHead, IndexTail>> for Cons<Head, Tail>
where
OtherTail: HList,
IndexHead: Index,
IndexTail: ManyIndex,
Self: Remove<OtherHead, IndexHead>,
<Self as Remove<OtherHead, IndexHead>>::Remainder: RemoveMany<OtherTail, IndexTail>,
{
type Remainder = <<Self as Remove<OtherHead, IndexHead>>::Remainder as RemoveMany<
OtherTail,
IndexTail,
>>::Remainder;
fn remove_many(self) -> (Cons<OtherHead, OtherTail>, Self::Remainder) {
let (head, remainder) = self.remove();
let (tail, remainder) = remainder.remove_many();
let list = Cons(head, tail);
(list, remainder)
}
}