[no description]
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 43 |
1 files changed, 41 insertions, 2 deletions
@@ -1,4 +1,9 @@ -#![feature(tuple_trait, import_trait_associated_functions, never_type)] +#![feature( + tuple_trait, + import_trait_associated_functions, + never_type, + iter_next_chunk +)] #![no_std] #![allow(mixed_script_confusables, confusable_idents)] //!  @@ -7,7 +12,10 @@ mod implementations; mod iterator; mod picks; -pub use iterator::IteratorOfTuples; +pub use iterator::{ + IteratorOfReferencesToTuple, IteratorOfReferencesToTupleWithF, + IteratorOfTuples, IteratorOfTuplesWithF, +}; /// Reverse a tuple. pub trait Reverse: Tupl { type Reversed: Tupl; @@ -89,10 +97,31 @@ pub trait Pick<const N: usize>: Tupl { fn depict(self) -> (Self::L, Self::At, Self::R); } +pub trait RefIze { + type AsRef<'a> + where + Self: 'a; + type AsMut<'a> + where + Self: 'a; + fn as_ref(&self) -> Self::AsRef<'_>; + fn as_mut(&mut self) -> Self::AsMut<'_>; +} + pub trait RePick<const N: usize, T>: Pick<N> + Sized { type New: Tupl; fn unpick(l: Self::L, at: T, r: Self::R) -> Self::New; } + +/// trait for mapping all elements of a tuple +pub trait MapAll<R: Tupl, Fns: Tupl>: Sized { + fn map_all(self, functions: Fns) -> R; +} +/// trait for mapping all elements of a tuple (FnMut edition). +pub trait MapAllMut<R: Tupl, Fns: Tupl> { + fn map_all_mut(self, functions: &mut Fns) -> R; +} + /// Main tuple trait. #[diagnostic::on_unimplemented( label = "this is not a tuple, or it is too big a tuple (>26 elements)" @@ -187,4 +216,14 @@ fn t() { .push(4) .push(0u8) .pick::<3>(); + + assert_eq!( + (1, 2u8, 3u16, "4").map_all(( + |_| {}, + |x| x + 1, + |x| x / 3, + |x| x.parse::<u32>().unwrap(), + )), + ((), 3, 1, 4) + ); } |