use crate::cons::traits::does_not_contain::DoesNotContain;
use crate::cons::{Cons, ConsCell, Nil};
use typenum_uuid_trait::TypeId;
pub trait Distinct: ConsCell {}
impl<C: Cons> Distinct for C
where
<C as Cons>::Head: TypeId,
C::Tail: DoesNotContain<C::Head>,
C::Tail: Distinct,
{
}
impl<NilSeed> Distinct for Nil<NilSeed> {}
#[cfg(test)]
mod tests {
use super::*;
use crate::cons::ConsCell;
use crate::cons::test_types::*;
use crate::cons::types::hcons::HNil;
fn only_distinct<C: ConsCell + Distinct>(_: C) {}
#[test]
fn it_works() {
let c = HNil::new().extend(U8(1)).extend(U32(2));
only_distinct(HNil::new());
only_distinct(c);
}
}