cons_cell 0.1.0

Swiss knife for heterogenous containers
Documentation
use crate::cons::ConsCell;
use crate::cons::traits::distinct::Distinct;
use crate::cons::traits::switches::contains_many_switch::ContainsAnySwitch;
use typenum::False;
// TODO: Reason about multiple equal types.

pub trait DoesNotContainMany<Contained: ConsCell + Distinct>: ConsCell {}

impl<Contained: ConsCell + Distinct, Container: ConsCell> DoesNotContainMany<Contained>
    for Container
where
    Container: ContainsAnySwitch<Contained, Value = False>,
{
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::cons::ConsCell;
    use crate::cons::test_types::*;
    use crate::cons::types::hcons::{HCons, HNil};

    fn only_does_not_contain_many<
        Contained: ConsCell + Distinct,
        C: DoesNotContainMany<Contained>,
    >(
        _: &C,
    ) {
    }

    #[test]
    fn does_not_contain_many() {
        let c = HNil::new().extend(U8(1)).extend(U32(2)).extend(U64(3));
        only_does_not_contain_many::<HCons<U16, HCons<U8, HNil>>, _>(&c);

        // Does not compile
        //only_does_not_contain_many::<HCons<U8, HCons<U64, HNil>>, _>(&c);
    }
}