#![allow(non_snake_case, clippy::unused_unit)]
#![doc = include_str!("../README.md")]
#![forbid(unsafe_code)]
#![no_std]
pub mod fns;
use fns::*;
mod seal {
pub trait Sealed {}
}
pub type TupleIndex<T, const INDEX: usize> = <T as IndexableTuple<INDEX>>::Value;
pub trait DynTuple: seal::Sealed {
fn arity(&self) -> usize;
}
pub trait Tuple: DynTuple + Sized {
const ARITY: usize;
}
pub trait JoinableTuple<T: JoinableTuple<Self>>: Tuple {
type Join: Tuple;
fn join(self, other: T) -> Self::Join;
}
pub trait GrowableTuple: Tuple {
type Append<T>: NonEmptyTuple<TruncateTail = Self, Tail = T>;
type Prepend<T>: NonEmptyTuple<Head = T, TruncateHead = Self>;
fn append<T>(self, value: T) -> Self::Append<T>;
fn prepend<T>(self, value: T) -> Self::Prepend<T>;
}
pub trait NonEmptyTuple: Tuple {
type Head;
type Tail;
type TruncateHead: GrowableTuple<Prepend<Self::Head> = Self>;
type TruncateTail: GrowableTuple<Append<Self::Tail> = Self>;
fn head(&self) -> &Self::Head;
fn head_mut(&mut self) -> &mut Self::Head;
fn tail(&self) -> &Self::Tail;
fn tail_mut(&mut self) -> &mut Self::Tail;
fn truncate_head(self) -> (Self::Head, Self::TruncateHead);
fn truncate_tail(self) -> (Self::TruncateTail, Self::Tail);
}
pub trait NonUnaryTuple: NonEmptyTuple<TruncateHead: NonEmptyTuple<Tail = Self::Tail>, TruncateTail: NonEmptyTuple<Head = Self::Head>> {
type TruncateHeadTail: GrowableTuple<Prepend<Self::Head> = Self::TruncateTail, Append<Self::Tail> = Self::TruncateHead>;
fn head_tail(&self) -> (&Self::Head, &Self::Tail);
fn head_tail_mut(&mut self) -> (&mut Self::Head, &mut Self::Tail);
fn truncate_head_tail(self) -> (Self::Head, Self::TruncateHeadTail, Self::Tail);
}
pub trait IndexableTuple<const INDEX: usize>: NonEmptyTuple {
type Value;
fn get(&self) -> &Self::Value;
fn get_mut(&mut self) -> &mut Self::Value;
fn into_index(self) -> Self::Value;
}
tupl_macros::impl_traits!();