tuple_split

Function split_tuple_at

Source
pub const fn split_tuple_at<const MIDDLE: usize, T>(
    tuple: T,
) -> (T::Left, T::Right)
where T: TupleSplitAt<MIDDLE>,
Expand description

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.

use tupleops::concat_tuples;
use tuple_split::*;

let t: (u8, f32, &str) = (1, 1.0, "test");
let (l, r): ((u8, f32), (&str,)) = split_tuple_at::<2, _>(t);

assert_eq!(t, concat_tuples(l, r));