tuple_split 0.2.4

An extension for the tupleops crate which adds a trait for splitting tuples.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
#![no_std]
#![feature(trait_alias)]
#![feature(generic_const_exprs)]
#![feature(const_trait_impl)]
#![feature(const_precise_live_drops)]
#![feature(tuple_trait)]
#![recursion_limit = "512"]

//!
//! This crate an extension for the [tupleops](tupleops) crate.
//!
//! [tupleops](tupleops) contains many useful features for manipulating tuples andusing tuples in generic code.
//! However, it does not support any kind of splitting of tuples. This crate adds that feature.
//!
//! # Examples
//!
//! ```rust
//! #![feature(generic_const_exprs)]
//!
//! let t = (32, 0.707, "test");
//!
//! // Splitting tuples by index
//! let (l, r) = tuple_split::split_tuple_at::<0, _>(t);
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//!
//! let (l, r) = tuple_split::split_tuple_at::<1, _>(t);
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//!
//! let (l, r) = tuple_split::split_tuple_at::<2, _>(t);
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//!
//! let (l, r) = tuple_split::split_tuple_at::<3, _>(t);
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//!
//! // Splitting tuples given a left side
//! let (l, r) = tuple_split::split_tuple_into_left::<(u8, f32), _>(t);
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//!
//! // Splitting tuples given a right side
//! let (l, r) = tuple_split::split_tuple_into_right::<(&str,), _>(t);
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//!
//! // Splitting tuples given both sides
//! let (l, r) = tuple_split::split_tuple_into::<(u8, f32), (&str,)>(t);
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//! ```
//!
//! # Split by index
//!
//! Tuples can be split by a const-generic index. To use this feature, put `#![feature(generic_const_exprs)]` on the top of your `lib.rs` or `main.rs`.
//!
//! ## Example
//!
//! ```rust
//! #![feature(generic_const_exprs)]
//!
//! let t = (1, 1.0, "test");
//!
//! let (l, r) = tuple_split::split_tuple_at::<2, _>(t);
//!
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//! ```
//!
//! # Split by type
//!
//! The type of tuple you want from the split operation can be used instead of an index. This does not require `#![feature(generic_const_exprs)]`. Either the left, right
//! or both can be provided as a generic type.
//!
//! ## Examples
//!
//! ### Left
//!
//! ```rust
//! let t = (1, 1.0, "test");
//!
//! let (l, r) = tuple_split::split_tuple_into_left::<(u8, f32), _>(t);
//!
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//! ```
//!
//! ### Right
//!
//! ```rust
//! let t = (1, 1.0, "test");
//!
//! let (l, r) = tuple_split::split_tuple_into_right::<(&str,), _>(t);
//!
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//! ```
//!
//! ### Both
//!
//! ```rust
//! let t = (1, 1.0, "test");
//!
//! let (l, r) = tuple_split::split_tuple_into::<(u8, f32), (&str,)>(t);
//!
//! assert_eq!(t, tupleops::concat_tuples(l, r));
//! ```
//!
//! ## Tuple sizes
//!
//! By default, this crate operates with tuples of up to 16 elements, just like the [tupleops](https://crates.io/crates/tupleops) crate.
//! If you want to use differently sized tuples, use the features `8`, `16`, `32`, `64`, `96`, `128`, `160`, `192`, `224` or `256` to set the maximum supported tuple
//! size.
//!
//! The `dont_hurt_yourself_by_using_all_features` is there to prevent usage of tuples bigger than 8 if `cargo` is ran with the flag `--all-features`.
//! Using a tuple size above 16 is highly discouraged as it will make compilation time unbearably long. Compilation time will increase exponentially.
//! You have been warned.

use core::marker::Tuple;

use blk_count_macro::count;
use tupleops::{ConcatTuples, TupleConcat};

/// Type alias [Left](Left) equals [TupleSplit::Left](TupleSplit::Left)
/// for any tuple which implements [TupleSplit](crate::TupleSplit) at the given MIDDLE.
pub type Left<T, const MIDDLE: usize> = <T as TupleSplitAt<MIDDLE>>::Left;
/// Type alias [Right](Right) equals [TupleSplit::Right](TupleSplit::Right)
/// for any tuple which implements [TupleSplit](crate::TupleSplit) at the given MIDDLE.
pub type Right<T, const MIDDLE: usize> = <T as TupleSplitAt<MIDDLE>>::Right;

/// Tuples which may be split at index `MIDDLE` have the trait [TupleSplitAt](crate::TupleSplitAt),
/// which, when split, returns [TupleSplitAt::Left](TupleSplitAt::Left), [TupleSplitAt::Right](TupleSplitAt::Right).
///
/// # Example
///
/// ```rust
/// #![feature(generic_const_exprs)]
///
/// let t = (1, 1.0, "test");
///
/// let (l, r) = tuple_split::split_tuple_at::<2, _>(t);
///
/// assert_eq!(t, tupleops::concat_tuples(l, r));
/// ```
#[diagnostic::on_unimplemented(message = "`{Self}` cannot be split at index `{MIDDLE}`")]
#[const_trait]
pub trait TupleSplitAt<const MIDDLE: usize>: Tuple
{
    type Left: Tuple;
    type Right: Tuple;

    fn split_tuple_at(self) -> (Self::Left, Self::Right);
}

/// A trait for splitting a tuple up into two parts given a specified left part `L` and right part `R`. `L` and `R` must be the left and right part of `Self`.
///
/// Tuples will be split into parts `L` and `R`.
///
/// # Example
///
/// ```rust
/// let t = (1, 1.0, "test");
///
/// let (l, r) = tuple_split::split_tuple_into::<(u8, f32), (&str,)>(t);
///
/// assert_eq!(t, tupleops::concat_tuples(l, r));
/// ```
#[diagnostic::on_unimplemented(message = "`{Self}` cannot be split up into `{L}` and `{R}`")]
#[const_trait]
pub trait TupleSplitInto<L, R>: ~const TupleSplitIntoLeft<L, Right = R> + ~const TupleSplitIntoRight<R, Left = L>
where
    L: Tuple,
    R: Tuple
{
    fn split_tuple_into(self) -> (L, R);
}

impl<T, L, R> const TupleSplitInto<L, R> for T
where
    Self: ~const TupleSplitIntoLeft<L, Right = R> + ~const TupleSplitIntoRight<R, Left = L>,
    L: Tuple,
    R: Tuple
{
    fn split_tuple_into(self) -> (L, R)
    {
        self.split_tuple_into_left()
    }
}

/// A trait for splitting a tuple up into two parts given a specified left part `L`. `L` must be a leftmost segment of `Self`.
///
/// Tuples will be split into parts `L` and [TupleSplitIntoLeft::Right](TupleSplitIntoLeft::Right).
///
/// # Example
///
/// ```rust
/// let t = (1, 1.0, "test");
///
/// let (l, r) = tuple_split::split_tuple_into_left::<(u8, f32), _>(t);
///
/// assert_eq!(t, tupleops::concat_tuples(l, r));
/// ```
#[diagnostic::on_unimplemented(message = "`{L}` is not the left part of `{Self}`")]
#[const_trait]
pub trait TupleSplitIntoLeft<L>: Tuple
where
    L: Tuple
{
    type Right: Tuple;

    fn split_tuple_into_left(self) -> (L, Self::Right);
}

/// A trait for splitting a tuple up into two parts given a specified right part `R`. `R` must be a rightmost segment of `Self`.
///
/// Tuples will be split into parts [TupleSplitIntoRight::Left](TupleSplitIntoRight::Left) and `R`.
///
/// # Example
///
/// ```rust
/// let t = (1, 1.0, "test");
///
/// let (l, r) = tuple_split::split_tuple_into_right::<(&str,), _>(t);
///
/// assert_eq!(t, tupleops::concat_tuples(l, r));
/// ```
#[diagnostic::on_unimplemented(message = "`{R}` is not the right part of `{Self}`")]
#[const_trait]
pub trait TupleSplitIntoRight<R>: Tuple
where
    R: Tuple
{
    type Left: Tuple;

    fn split_tuple_into_right(self) -> (Self::Left, R);
}

/// Splits tuple at a given index.
///
/// Index is specified as const generic `MIDDLE.
///
/// Tuple must be of trait `[TupleSplitAt](crate::TupleSplitAt)<MIDDLE>`.
///
/// Returns `([TupleSplitAt::Left](TupleSplitAt::Left), [TupleSplitAt::Right](TupleSplitAt::Right))` for the given Tuple and `MIDDLE`.
///
/// ```rust
/// #![feature(generic_const_exprs)]
///
/// let t = (1, 1.0, "test");
///
/// let (l, r) = tuple_split::split_tuple_at::<2, _>(t);
///
/// assert_eq!(t, tupleops::concat_tuples(l, r));
/// ```
pub const fn split_tuple_at<const MIDDLE: usize, T>(tuple: T) -> (T::Left, T::Right)
where
    T: ~const TupleSplitAt<MIDDLE>
{
    tuple.split_tuple_at()
}

/// A trait for splitting a tuple up into two parts given a specified left part `L` and right part `R`. `L` and `R` must be the left and right part of `Self`.
///
/// Tuples will be split into parts `L` and `R`.
///
/// # Example
///
/// ```rust
/// let t = (1, 1.0, "test");
///
/// let (l, r) = tuple_split::split_tuple_into::<(u8, f32), (&str,)>(t);
///
/// assert_eq!(t, tupleops::concat_tuples(l, r));
/// ```
pub const fn split_tuple_into<L, R>(tuple: ConcatTuples<L, R>) -> (L, R)
where
    L: Tuple,
    R: Tuple,
    (L, R): TupleConcat<L, R>,
    ConcatTuples<L, R>: ~const TupleSplitInto<L, R>
{
    tuple.split_tuple_into()
}

/// Splits a tuple up into two parts given a specified left part `L`. `L` must be a leftmost segment of `Self`.
///
/// Tuples will be split into parts `L` and [TupleSplitIntoLeft::Right](TupleSplitIntoLeft::Right).
///
/// # Example
///
/// ```rust
/// let t = (1, 1.0, "test");
///
/// let (l, r) = tuple_split::split_tuple_into_left::<(u8, f32), _>(t);
///
/// assert_eq!(t, tupleops::concat_tuples(l, r));
/// ```
pub const fn split_tuple_into_left<L, T>(tuple: T) -> (L, T::Right)
where
    L: Tuple,
    T: ~const TupleSplitIntoLeft<L>
{
    tuple.split_tuple_into_left()
}

/// Splits a tuple up into two parts given a specified right part `R`. `R` must be a rightmost segment of `Self`.
///
/// Tuples will be split into parts [TupleSplitIntoRight::Left](TupleSplitIntoRight::Left) and `R`.
///
/// # Example
///
/// ```rust
/// let t = (1, 1.0, "test");
///
/// let (l, r) = tuple_split::split_tuple_into_right::<(&str,), _>(t);
///
/// assert_eq!(t, tupleops::concat_tuples(l, r));
/// ```
pub const fn split_tuple_into_right<R, T>(tuple: T) -> (T::Left, R)
where
    R: Tuple,
    T: ~const TupleSplitIntoRight<R>
{
    tuple.split_tuple_into_right()
}

macro_rules! impl_split_single {
    (( $($types1:ident),* ), ( $($types2:ident),* )) => {
        impl<$($types1,)* $($types2,)*> const TupleSplitAt<{count!($($types1),*)}> for ($($types1,)* $($types2,)*)
        {
            type Left = ($($types1,)*);
            type Right = ($($types2,)*);

            fn split_tuple_at(self) -> (Self::Left, Self::Right)
            {
                let ($($types1,)* $($types2,)*) = self;
                (($($types1,)*), ($($types2,)*))
            }
        }

        impl<$($types1,)* $($types2,)*> const TupleSplitIntoLeft<($($types1,)*)> for ($($types1,)* $($types2,)*)
        {
            type Right = ($($types2,)*);

            fn split_tuple_into_left(self) -> (($($types1,)*), ($($types2,)*))
            {
                let ($($types1,)* $($types2,)*) = self;
                (($($types1,)*), ($($types2,)*))
            }
        }
        impl<$($types1,)* $($types2,)*> const TupleSplitIntoRight<($($types2,)*)> for ($($types1,)* $($types2,)*)
        {
            type Left = ($($types1,)*);

            fn split_tuple_into_right(self) -> (($($types1,)*), ($($types2,)*))
            {
                let ($($types1,)* $($types2,)*) = self;
                (($($types1,)*), ($($types2,)*))
            }
        }
    };
}
macro_rules! impl_split_combinations {
    ( (), ( $($types2:ident),* ) ) => {
        impl_split_single!{(), ($($types2),*)}
    };
    (($t0:ident $(,$types1:ident)* ), ( $($types2:ident),* )) => {
        impl_split_single!{($t0 $(,$types1)*), ($($types2),*)}

        impl_split_combinations!{($($types1),*), ($t0 $(,$types2)*)}
    };
    (($($types:ident),*)) => {
        impl_split_combinations!{($($types),*), ()}
    }
}
macro_rules! impl_split_all {
    (()) => {
        impl_split_combinations!{()}
    };
    (($t0:ident $(,$types:ident)*)) => {
        impl_split_combinations!{($t0 $(,$types)*)}

        impl_split_all!{($($types),*)}
    }
}

#[cfg(not(feature = "8"))]
impl_split_all! {
    (
        _1, _2, _3, _4
    )
}

#[cfg(feature = "8")]
#[cfg(any(feature = "dont_hurt_yourself_by_using_all_features", not(feature = "16")))]
impl_split_all! {
    (
        _1, _2, _3, _4, _5, _6, _7, _8
    )
}

#[cfg(feature = "16")]
#[cfg(not(feature = "dont_hurt_yourself_by_using_all_features"))]
#[cfg(not(feature = "32"))]
impl_split_all! {
    (
        _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16
    )
}

#[cfg(feature = "32")]
#[cfg(not(feature = "dont_hurt_yourself_by_using_all_features"))]
#[cfg(not(feature = "64"))]
impl_split_all! {
    (
        _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16,
        _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32
    )
}

#[cfg(feature = "64")]
#[cfg(not(feature = "dont_hurt_yourself_by_using_all_features"))]
#[cfg(not(feature = "96"))]
impl_split_all! {
    (
        _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16,
        _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32,
        _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48,
        _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64
    )
}

#[cfg(feature = "96")]
#[cfg(not(feature = "dont_hurt_yourself_by_using_all_features"))]
#[cfg(not(feature = "128"))]
impl_split_all! {
    (
        _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16,
        _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32,
        _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48,
        _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64,
        _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80,
        _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96
    )
}

#[cfg(feature = "128")]
#[cfg(not(feature = "dont_hurt_yourself_by_using_all_features"))]
#[cfg(not(feature = "160"))]
impl_split_all! {
    (
        _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16,
        _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32,
        _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48,
        _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64,
        _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80,
        _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96,
        _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112,
        _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128
    )
}

#[cfg(feature = "160")]
#[cfg(not(feature = "dont_hurt_yourself_by_using_all_features"))]
#[cfg(not(feature = "192"))]
impl_split_all! {
    (
        _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16,
        _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32,
        _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48,
        _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64,
        _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80,
        _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96,
        _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112,
        _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128,
        _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144,
        _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160
    )
}

#[cfg(feature = "192")]
#[cfg(not(feature = "dont_hurt_yourself_by_using_all_features"))]
#[cfg(not(feature = "224"))]
impl_split_all! {
    (
        _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16,
        _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32,
        _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48,
        _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64,
        _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80,
        _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96,
        _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112,
        _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128,
        _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144,
        _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160,
        _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176,
        _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192
    )
}

#[cfg(feature = "224")]
#[cfg(not(feature = "dont_hurt_yourself_by_using_all_features"))]
#[cfg(not(feature = "256"))]
impl_split_all! {
    (
        _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16,
        _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32,
        _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48,
        _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64,
        _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80,
        _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96,
        _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112,
        _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128,
        _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144,
        _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160,
        _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176,
        _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192,
        _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208,
        _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224
    )
}

#[cfg(not(feature = "dont_hurt_yourself_by_using_all_features"))]
#[cfg(feature = "256")]
impl_split_all! {
    (
        _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16,
        _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32,
        _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48,
        _49, _50, _51, _52, _53, _54, _55, _56, _57, _58, _59, _60, _61, _62, _63, _64,
        _65, _66, _67, _68, _69, _70, _71, _72, _73, _74, _75, _76, _77, _78, _79, _80,
        _81, _82, _83, _84, _85, _86, _87, _88, _89, _90, _91, _92, _93, _94, _95, _96,
        _97, _98, _99, _100, _101, _102, _103, _104, _105, _106, _107, _108, _109, _110, _111, _112,
        _113, _114, _115, _116, _117, _118, _119, _120, _121, _122, _123, _124, _125, _126, _127, _128,
        _129, _130, _131, _132, _133, _134, _135, _136, _137, _138, _139, _140, _141, _142, _143, _144,
        _145, _146, _147, _148, _149, _150, _151, _152, _153, _154, _155, _156, _157, _158, _159, _160,
        _161, _162, _163, _164, _165, _166, _167, _168, _169, _170, _171, _172, _173, _174, _175, _176,
        _177, _178, _179, _180, _181, _182, _183, _184, _185, _186, _187, _188, _189, _190, _191, _192,
        _193, _194, _195, _196, _197, _198, _199, _200, _201, _202, _203, _204, _205, _206, _207, _208,
        _209, _210, _211, _212, _213, _214, _215, _216, _217, _218, _219, _220, _221, _222, _223, _224,
        _225, _226, _227, _228, _229, _230, _231, _232, _233, _234, _235, _236, _237, _238, _239, _240,
        _241, _242, _243, _244, _245, _246, _247, _248, _249, _250, _251, _252, _253, _254, _255, _256
    )
}

#[cfg(test)]
mod tests
{
    use crate as tuple_split;

    #[test]
    fn test_split_concat()
    {
        let t: (u8, f32, &str) = (1, 1.0, "test");

        let (l, r) = tuple_split::split_tuple_at::<0, _>(t);
        assert_eq!(t, tupleops::concat_tuples(l, r));

        let (l, r) = tuple_split::split_tuple_at::<1, _>(t);
        assert_eq!(t, tupleops::concat_tuples(l, r));

        let (l, r) = tuple_split::split_tuple_at::<2, _>(t);
        assert_eq!(t, tupleops::concat_tuples(l, r));

        let (l, r) = tuple_split::split_tuple_at::<3, _>(t);
        assert_eq!(t, tupleops::concat_tuples(l, r));
    }

    #[cfg(feature = "8")]
    #[test]
    fn test()
    {
        let t = (1u8, 2u16, 3u32, 4u64, 5u128);

        let (l1, r1) = tuple_split::split_tuple_into_left::<(u8, u16), _>(t);
        let (l2, r2) = tuple_split::split_tuple_into_right::<(u32, u64, u128), _>(t);
        let (l3, r3) = tuple_split::split_tuple_at::<2, _>(t);

        assert_eq!(l1, l2);
        assert_eq!(l2, l3);

        assert_eq!(r1, r2);
        assert_eq!(r2, r3);

        assert_eq!(t, tupleops::concat_tuples(l1, r1));
        assert_eq!(t, tupleops::concat_tuples(l2, r2));
        assert_eq!(t, tupleops::concat_tuples(l3, r3));
    }
}

/*mod private
{
    use core::{marker::Tuple, mem::ManuallyDrop};

    use tupleops::{ConcatTuples, TupleConcat};

    union TupleConcatTransmutation<L, R>
    where
        L: Tuple,
        R: Tuple,
        (L, R): TupleConcat<L, R, Type: Tuple>
    {
        split: ManuallyDrop<(ManuallyDrop<L>, ManuallyDrop<R>)>,
        concat: ManuallyDrop<ConcatTuples<L, R>>
    }

    /// TODO: find a safe way to do this.
    /// According to language specifications, the compiler can re-order elements in a tuple in any way in memory.
    /// This function assumes they are in-order.
    /// It works, i guess? (so far)
    /// It's only because the compiler happens to do it like i assumed (most of the time, i think...)
    #[deprecated(note = "This is undefined behaviour")]
    pub const fn tuple_split_const_hold<L, R>(tuple: ConcatTuples<L, R>) -> (ManuallyDrop<L>, ManuallyDrop<R>)
    where
        L: Tuple,
        R: Tuple,
        (L, R): TupleConcat<L, R, Type: Tuple>
    {
        assert!(
            core::mem::size_of::<(ManuallyDrop<L>, ManuallyDrop<R>)>() == core::mem::size_of::<ConcatTuples<L, R>>(),
            "You just ran into undefined behaviour. Please report it on https://github.com/sigurd4/fn_zip/issues."
        );
        unsafe {
            ManuallyDrop::into_inner(
                TupleConcatTransmutation {
                    concat: ManuallyDrop::new(tuple)
                }
                .split
            )
        }
    }

    /*#[deprecated(note = "This is undefined behaviour")]
    pub const fn tuple_split_const<L, R>(tuple: ConcatTuples<L, R>) -> (L, R)
    where
        L: Tuple,
        R: Tuple,
        (L, R): TupleConcat<L, R, Type: Tuple>
    {
        let (left, right) = tuple_split_const_hold(tuple);
        (ManuallyDrop::into_inner(left), ManuallyDrop::into_inner(right))
    }*/
}*/