Crate tuple_split

source ·
Expand description

This crate is an extension for the tupleops crate, which adds a trait for splitting tuples by index.

Tuples which may be split at index MIDDLE have the trait TupleSplit, which, when split, returns (TupleSplit::Left, TupleSplit::Right).

Type alias Left and Right equal TupleSplit::Left and TupleSplit::Right respectively. fpr any tuple which implements TupleSplit at the given MIDDLE.

The trait alias SplitLeftInto is implemented for any tuple which may be split where TupleSplit::Left = L.

The trait alias SplitRightInto is implemented for any tuple which may be split where TupleSplit::Right = R.

The trait alias SplitInto is implemented for any tuple which may be split where TupleSplit::Left = L and TupleSplit::Right = R.

use tupleops::concat_tuples;
use tuple_split::*;
 
let t: (u8, f32, &str) = (1, 1.0, "test");
 
let (l, r): ((u8, f32), (&str,)) = TupleSplit::<2>::split_tuple(t);
 
assert_eq!(t, concat_tuples(l, r));
 
let (l, r): ((u8, f32), (&str,)) = split_tuple::<2, _>(t);
 
assert_eq!(t, concat_tuples(l, r));

Traits

Functions

Type Definitions

Trait Aliases