use core::pin::Pin;
use array_trait::Array;
use slice_ops::AsSlice;
use crate::form::ArrayForm;
use super::ArrayZipWith;
#[const_trait]
pub trait ArrayZip<T, const N: usize>: Array + AsSlice<Item = T>
{
fn zip<Z>(self, other: Z) -> [(T, Z::Elem); N]
where
Z: ArrayForm<N>;
fn zip_ref<Z>(&self, other: Z) -> [(&T, Z::Elem); N]
where
Z: ArrayForm<N>;
fn zip_mut<Z>(&mut self, other: Z) -> [(&mut T, Z::Elem); N]
where
Z: ArrayForm<N>;
fn zip_pin_ref<Z>(self: Pin<&Self>, other: Z) -> [(Pin<&T>, Z::Elem); N]
where
Z: ArrayForm<N>;
fn zip_pin_mut<Z>(self: Pin<&mut Self>, other: Z) -> [(Pin<&mut T>, Z::Elem); N]
where
Z: ArrayForm<N>;
}
impl<T, const N: usize> ArrayZip<T, N> for [T; N]
{
fn zip<Z>(self, other: Z) -> [(T, Z::Elem); N]
where
Z: ArrayForm<N>
{
self.zip_with(other, const |x, y| (x, y))
}
fn zip_ref<Z>(&self, other: Z) -> [(&T, Z::Elem); N]
where
Z: ArrayForm<N>
{
self.zip_ref_with(other, const |x, y| (x, y))
}
fn zip_mut<Z>(&mut self, other: Z) -> [(&mut T, Z::Elem); N]
where
Z: ArrayForm<N>
{
self.zip_mut_with(other, const |x, y| (x, y))
}
fn zip_pin_ref<Z>(self: Pin<&Self>, other: Z) -> [(Pin<&T>, Z::Elem); N]
where
Z: ArrayForm<N>
{
self.zip_pin_ref_with(other, const |x, y| (x, y))
}
fn zip_pin_mut<Z>(self: Pin<&mut Self>, other: Z) -> [(Pin<&mut T>, Z::Elem); N]
where
Z: ArrayForm<N>
{
self.zip_pin_mut_with(other, const |x, y| (x, y))
}
}