iter2 0.1.0

Iterator `chain`ing, `cmp`ing and more as free functions taking two `IntoIterator`s
Documentation
#![no_std]

use core::{cmp::Ordering, iter::Chain};

pub use core::iter::zip;

/// Shorthand for `a.into_iter().chain(b)`.
pub fn chain<A, B>(a: A, b: B) -> Chain<A::IntoIter, B::IntoIter>
where
    A: IntoIterator,
    B: IntoIterator<Item = A::Item>,
{
    a.into_iter().chain(b)
}

/// Shorthand for `a.into_iter().cmp(b)`.
pub fn cmp<A, B>(a: A, b: B) -> Ordering
where
    A: IntoIterator,
    A::Item: Ord,
    B: IntoIterator<Item = A::Item>,
{
    a.into_iter().cmp(b)
}

/// Shorthand for `a.into_iter().partial_cmp(b)`.
pub fn partial_cmp<A, B>(a: A, b: B) -> Option<Ordering>
where
    A: IntoIterator,
    A::Item: PartialOrd<B::Item>,
    B: IntoIterator,
{
    a.into_iter().partial_cmp(b)
}

/// Shorthand for `a.into_iter().eq(b)`.
pub fn eq<A, B>(a: A, b: B) -> bool
where
    A: IntoIterator,
    A::Item: PartialEq<B::Item>,
    B: IntoIterator,
{
    a.into_iter().eq(b)
}

/// Shorthand for `a.into_iter().ne(b)`.
pub fn ne<A, B>(a: A, b: B) -> bool
where
    A: IntoIterator,
    A::Item: PartialEq<B::Item>,
    B: IntoIterator,
{
    a.into_iter().ne(b)
}

/// Shorthand for `a.into_iter().le(b)`.
pub fn le<A, B>(a: A, b: B) -> bool
where
    A: IntoIterator,
    A::Item: PartialOrd<B::Item>,
    B: IntoIterator,
{
    a.into_iter().le(b)
}

/// Shorthand for `a.into_iter().lt(b)`.
pub fn lt<A, B>(a: A, b: B) -> bool
where
    A: IntoIterator,
    A::Item: PartialOrd<B::Item>,
    B: IntoIterator,
{
    a.into_iter().lt(b)
}

/// Shorthand for `a.into_iter().ge(b)`.
pub fn ge<A, B>(a: A, b: B) -> bool
where
    A: IntoIterator,
    A::Item: PartialOrd<B::Item>,
    B: IntoIterator,
{
    a.into_iter().ge(b)
}

/// Shorthand for `a.into_iter().gt(b)`.
pub fn gt<A, B>(a: A, b: B) -> bool
where
    A: IntoIterator,
    A::Item: PartialOrd<B::Item>,
    B: IntoIterator,
{
    a.into_iter().gt(b)
}